Jump to content


Photo

close window button


  • Please log in to reply
5 replies to this topic

#1 knowram

knowram
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts

Posted 05 June 2006 - 03:56 PM

I have a page that reloads itself every time you hit a different submit button. I am trying to put a button on the bottom of the page that the user can use to close the window when they are done. Here is the code that I am using so fare

        <input type="button" value="Close Window" onClick="self.close();" >

this works great the first time the page loads if that is the first thing you click. But if you use a different button which reloads the page the close window button will no longer work.

anyone know how to fix this problem?

#2 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 05 June 2006 - 05:20 PM

You only can close a window if it was open by a script. Once the page is reloaded (or the URL is changed) the page is not considered to be opened by a script anymore, so the self.close() won't work.

NoGray.com


#3 knowram

knowram
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts

Posted 05 June 2006 - 07:07 PM

is there anyway to use a link or button to close the window at that point?

#4 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 05 June 2006 - 08:48 PM

I don't think so, but I am not 100% sure.

Maybe if you tried to load the page content in an iframe and the button on the page itself.

NoGray.com


#5 knowram

knowram
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts

Posted 05 June 2006 - 11:26 PM

Great idea but I am passing information to the page through the link so I don't think i can use iframes. unless there is a way to pass information to an ifram with the link.

#6 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 05 June 2006 - 11:37 PM

you can trying something like this. Let's say you are passing ID as a variable to page.php?ID=3
<?PHP
$iframe_link = "iframe_page.php?ID=".$_GET['ID']
?>
<iframe src="<?= $iframe_link ?>"></iframe>
<button onclick="window.close();">Close</button>
this should pass the ID variable to the iframe page.

NoGray.com





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users