abhishekdeveloper Posted March 11, 2012 Share Posted March 11, 2012 Dear All, Below is my script for closing a window, I intend to close the window. Please help me out. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <title> Thank you! </title> <body bgcolor="#808080"> <br> <br> <h2><P ALIGN=Center>Thank you for voting on our website!</h2> <h3><P ALIGN=Center>We will e-mail you the results of the experiment shortly!</h3> <br> <br> <P ALIGN=Center><a href="login_success.php">Click here to go back and change your votes</a> <br> <br> <P ALIGN=Center><a href="" onclick="window.close();return false;">Click here to close this window</a> </body> </html> It is not working as I intend it to work, any suggestions?? Quote Link to comment https://forums.phpfreaks.com/topic/258687-error-while-trying-to-close-a-window-using-script/ Share on other sites More sharing options...
abhishekdeveloper Posted March 11, 2012 Author Share Posted March 11, 2012 Even if I try the below code, it gives me the error: Not Found The requested URL /self.close() was not found on this server. Here's the script: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <title> Thank you! </title> <body bgcolor="#808080"> <br> <br> <h2><P ALIGN=Center>Thank you for voting on our website!</h2> <h3><P ALIGN=Center>We will e-mail you the results of the experiment shortly!</h3> <br> <br> <P ALIGN=Center><a href="login_success.php">Click here to go back and change your votes</a> <br> <br> <P ALIGN=Center><a href="self.close()">Click here to close this window</a> </body> </html> Please suggest modifications asap. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/258687-error-while-trying-to-close-a-window-using-script/#findComment-1326135 Share on other sites More sharing options...
cpd Posted March 11, 2012 Share Posted March 11, 2012 You could try top.close(); or parent.window.close(); onclick="javascript: top.close();" Quote Link to comment https://forums.phpfreaks.com/topic/258687-error-while-trying-to-close-a-window-using-script/#findComment-1326187 Share on other sites More sharing options...
abhishekdeveloper Posted March 11, 2012 Author Share Posted March 11, 2012 I am not sure if my window is opened using javascript...and self only works if a window is opened using javascript. Can you please help me out in this regard? I want it to work on all the platforms. Thank you. You could try top.close(); or parent.window.close(); onclick="javascript: top.close();" Quote Link to comment https://forums.phpfreaks.com/topic/258687-error-while-trying-to-close-a-window-using-script/#findComment-1326191 Share on other sites More sharing options...
cpd Posted March 11, 2012 Share Posted March 11, 2012 What window are you trying to close then? If you're not trying to close a child window is it a main window or something completely different? You must know if its being created with JavaScript or not because you would have created it. Quote Link to comment https://forums.phpfreaks.com/topic/258687-error-while-trying-to-close-a-window-using-script/#findComment-1326196 Share on other sites More sharing options...
abhishekdeveloper Posted March 11, 2012 Author Share Posted March 11, 2012 It is a page written in html/php, i tried HTML script using self.close() but it is also giving the not found error...help! What window are you trying to close then? If you're not trying to close a child window is it a main window or something completely different? You must know if its being created with JavaScript or not because you would have created it. Quote Link to comment https://forums.phpfreaks.com/topic/258687-error-while-trying-to-close-a-window-using-script/#findComment-1326207 Share on other sites More sharing options...
cpd Posted March 11, 2012 Share Posted March 11, 2012 Why would you want to close a page you've just loaded if its the parent of your entire website? Quote Link to comment https://forums.phpfreaks.com/topic/258687-error-while-trying-to-close-a-window-using-script/#findComment-1326232 Share on other sites More sharing options...
abhishekdeveloper Posted March 11, 2012 Author Share Posted March 11, 2012 It is not the parent of the entire website...it is the page that opens after the user is done using the website for the purpose it was intended to do... Why would you want to close a page you've just loaded if its the parent of your entire website? Quote Link to comment https://forums.phpfreaks.com/topic/258687-error-while-trying-to-close-a-window-using-script/#findComment-1326239 Share on other sites More sharing options...
cpd Posted March 11, 2012 Share Posted March 11, 2012 So you open an entirely new window and then want to close it so they can view the main website again? In that case top.close() document.close() window.close() parent.window.close() should all work.... Quote Link to comment https://forums.phpfreaks.com/topic/258687-error-while-trying-to-close-a-window-using-script/#findComment-1326241 Share on other sites More sharing options...
abhishekdeveloper Posted March 11, 2012 Author Share Posted March 11, 2012 I am sorry but same error....I guess I need to put the source code file on the server in the same folder for all these functions self.close, windows.close() etc. So you open an entirely new window and then want to close it so they can view the main website again? In that case top.close() document.close() window.close() parent.window.close() should all work.... Quote Link to comment https://forums.phpfreaks.com/topic/258687-error-while-trying-to-close-a-window-using-script/#findComment-1326242 Share on other sites More sharing options...
rythemton Posted March 22, 2012 Share Posted March 22, 2012 If JavaScript did not open the window, then JavaScript cannot close the window in most web browsers. This was implemented as a Security Feature. Nothing you can do about it. If JavaScript did open the window, then your first script should work. Quote Link to comment https://forums.phpfreaks.com/topic/258687-error-while-trying-to-close-a-window-using-script/#findComment-1330276 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.