knowram Posted June 5, 2006 Share Posted June 5, 2006 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 [code] <input type="button" value="Close Window" onClick="self.close();" >[/code]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? Quote Link to comment https://forums.phpfreaks.com/topic/11245-close-window-button/ Share on other sites More sharing options...
nogray Posted June 5, 2006 Share Posted June 5, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/11245-close-window-button/#findComment-42084 Share on other sites More sharing options...
knowram Posted June 5, 2006 Author Share Posted June 5, 2006 is there anyway to use a link or button to close the window at that point? Quote Link to comment https://forums.phpfreaks.com/topic/11245-close-window-button/#findComment-42129 Share on other sites More sharing options...
nogray Posted June 5, 2006 Share Posted June 5, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/11245-close-window-button/#findComment-42180 Share on other sites More sharing options...
knowram Posted June 5, 2006 Author Share Posted June 5, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/11245-close-window-button/#findComment-42220 Share on other sites More sharing options...
nogray Posted June 5, 2006 Share Posted June 5, 2006 you can trying something like this. Let's say you are passing ID as a variable to page.php?ID=3[code]<?PHP$iframe_link = "iframe_page.php?ID=".$_GET['ID']?><iframe src="<?= $iframe_link ?>"></iframe><button onclick="window.close();">Close</button>[/code]this should pass the ID variable to the iframe page. Quote Link to comment https://forums.phpfreaks.com/topic/11245-close-window-button/#findComment-42226 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.