...

View Full Version : Code for closing an internet page



Saz
09-21-2005, 02:06 PM
I've googled till my mouse is almost worn out, but no luck - Anyone know the php code for closing an internet page please?

Any help appreciated.

Saz.

NancyJ
09-21-2005, 02:27 PM
There is no such thing AFAIK. You can close a popup window with javascript and possibly a browser window but since php is executed on the server is has no control over the users browser.

Fou-Lu
09-21-2005, 03:22 PM
With Nancy's post, I'm pretty certain that javascript can close the main browser window, but I seem to recall that it prompts the user to accept the force closing option for it.
So to sum it up - not with php you can't.

marek_mar
09-21-2005, 04:46 PM
PHP has no contro of the browser. JS can close browser WINDOWS if you a) enable JS and B) when the window is not opened by JS it will ask you if it should be closed.

raf
09-21-2005, 07:19 PM
marek_mar is spot on.

i don't realy understand why you would want to close it. the user should decide if he wants to close it or not. i think that the closest you can get is moving the window so it drops out of sight, but that is not really accepted codingpractice ...

cseasy
09-21-2005, 10:32 PM
If you want to close the window based on a test in PHP, you could try:


<?php
$onload = "";
if (myTestSucceeds) {
$onload = " onload='window.close();'";
}
?>
<html>
<head>
<title></title>
</head>
<body<?php if ($onload) { ?><?=$onload?><?php } ?>>
page content
</body>
</html>

As mentioned before, if JavaScript didn't open the window, the user will be prompted to confirm the close, assuming JavaScript is enabled on their machine in the first place.

C.

felgall
09-21-2005, 11:12 PM
The rule is that you can't close a window that you didn't open. Since PHP can't open browser windows, it can't close them either.

If Javascript opened a window then it can close it. If Javascript tries to close a window it didn't open then some browsers ask for permission while others just ignore the request since it is not valid.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum