close window in php

close window command in php

Page 1 of 1

7 Replies - 21707 Views - Last Post: 19 February 2009 - 02:06 PM Rate Topic: -----

#1 nazar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 16-February 09

close window in php

Post icon  Posted 18 February 2009 - 11:46 PM

Hi there, new to .php

With html i had the close window command..

<input type="button" value="Close this window" onclick="self.close()">

as you can see, it is a simple command with a button...

renamed my index.html to index.php to get some .php code to work

but the button above now does not work??

:) searching on the net, they all talk about auto close's and ending scripts on close?????

just want to close a window on click :rolleyes:

thanks

Is This A Good Question/Topic? 0
  • +

Replies To: close window in php

#2 nazar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 16-February 09

Re: close window in php

Posted 19 February 2009 - 03:51 AM

i thought it would have been simple???????

maybe not

anyone got any ideas?????
Was This Post Helpful? 0
  • +
  • -

#3 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: close window in php

Posted 19 February 2009 - 04:11 AM

Have you tried window.close();?
Was This Post Helpful? 0
  • +
  • -

#4 nazar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 16-February 09

Re: close window in php

Posted 19 February 2009 - 05:18 AM

tried this, didn't work either

<input type="button" value="Close this window" onclick="window.close()">

??????????

the button dosen't highlight when the mouse goes over it like in html - so maybe it is a problem with the button function????

before you tell me i forgot ";" - tried this too

<input type="button" value="Close this window" onclick="window.close();">

This post has been edited by nazar: 19 February 2009 - 05:34 AM

Was This Post Helpful? 0
  • +
  • -

#5 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: close window in php

Posted 19 February 2009 - 06:37 AM

I've just done some reading about this because I wasn't sure. The essence of it is that Firefox will not let you close a window using javascript unless you previously opened it with javascript. IE seems to still close the window, but it shouldn't really, and even then it'll give you a security error if you run the file on your local machine.

Are you opening the window you are trying to close yourself?
Which browsers have you tried this on?

If you are trying to close a window that you have created through javascript, could you post a bit more of your code?
Was This Post Helpful? 0
  • +
  • -

#6 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2889
  • View blog
  • Posts: 10,004
  • Joined: 08-August 08

Re: close window in php

Posted 19 February 2009 - 08:01 AM

To close a window in php is simple: Don't open it!

PHP is server side, which means that it is done executing before the user sees anything. If you could open a window and then close it in php, the user would never see it.
Was This Post Helpful? 0
  • +
  • -

#7 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: close window in php

Posted 19 February 2009 - 08:03 AM

Well, yes, that is true. :rolleyes:

Maybe a moderator could move this to Web Dev or Javascript?
Was This Post Helpful? 0
  • +
  • -

#8 nazar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 16-February 09

Re: close window in php

Posted 19 February 2009 - 02:06 PM

hey guys, there wasen't a problem with the code - my original self.close works......

The problem was the new code that i had to make it index.php

the php code slightly over ran the button (even though you couldn't see it on the page)
:blink: you learn something new every day :D

i found it because i was setting up my testpage for you to look - and i was simplifying the page - and i completely seperated them .... and all of a sudden it worked?????

so after messing around i found out why.....

thanks for your help guys

oh to answer the question - the page is a popup and i wanted a button for the user to close when he/she was ready

thanks again for help

This post has been edited by nazar: 19 February 2009 - 02:09 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1