469,602 Members | 1,968 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

How to close browser window in PHP?

Is there a way to close the present (active) window using PHP code?
Jul 17 '05 #1
10 92323
RonS <ro**********@SPAMtds.net> wrote in news:40********@newspeer2.tds.net:
Is there a way to close the present (active) window using PHP code?


you can insert a javascript statement to close the window after the php
code is finished. But this would only be useful if the code is supposed to
do something that the user never sees the results from... or are passed to
another window I suppose. Such as opening a child window, performing some
code, passing the results to the parent, then closing the window.
Jul 17 '05 #2
In article <40********@newspeer2.tds.net>, RonS wrote:
Is there a way to close the present (active) window using PHP code?


PHP is executed at the server-side and thus does not know about clients,
browsers or windows of those browsers.

With JavaScript you might have access to call window.close on windows
you opened with the window.open function.

Why would you want to close someone's window anyway? Most people don't
like silly webdesigners trying to mess with their windows anyway.

--
Tim Van Wassenhove <http://home.mysth.be/~timvw/contact.php>
Jul 17 '05 #3

"Theo" <in*****@noemail.com> wrote in message
news:Xn************************@216.168.3.44...
RonS <ro**********@SPAMtds.net> wrote in news:40********@newspeer2.tds.net:
Is there a way to close the present (active) window using PHP code?


you can insert a javascript statement to close the window after the php
code is finished. But this would only be useful if the code is supposed to
do something that the user never sees the results from... or are passed to
another window I suppose. Such as opening a child window, performing some
code, passing the results to the parent, then closing the window.


<?php
echo '<BUTTON onclick="window.close();">Close me.</BUTTON>';
?>

Hey, it's PHP. ;-)

Garp
Jul 17 '05 #4
On Sun, 23 May 2004 00:42:26 -0500, RonS <ro**********@SPAMtds.net> wrote:
Is there a way to close the present (active) window using PHP code?


No.

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #5
In article <uy*******************@news-text.cableinet.net>, Garp wrote:
<?php
echo '<BUTTON onclick="window.close();">Close me.</BUTTON>';
?>

Hey, it's PHP. ;-)


Depends, if you feed a webbrowser the

<?php echo 'foo'; ?>

it will not think it's php :P

--
Tim Van Wassenhove <http://home.mysth.be/~timvw/contact.php>
Jul 17 '05 #6
Tim Van Wassenhove wrote:
PHP is executed at the server-side and thus does not know about clients,
browsers or windows of those browsers.

With JavaScript you might have access to call window.close on windows
you opened with the window.open function.

Why would you want to close someone's window anyway? Most people don't
like silly webdesigners trying to mess with their windows anyway.


Thanks for being so civil. Yes, I know about the Javascript and how PHP works.
And I know how frustrated some people get with seemingly obvious questions

I've got an app that displays a months worth of data from a database in a
window. When the user clicks on an entry in this window I open a separate small
editing window for just that days data. I know I can have a separate button for
the user to close the window with Javascript (which is the way it works now),
but would rather have the window 'automatically' close when the user submits the
changes.

In semi-pseudo code, I envisioned something like this:

// Code to check for updated variables after a submit
....
$blnDataChanged = TRUE;
if ($blnDataChanged) {
// Store hours and close window
...
//Redirect back to (and refresh) the data display window
exit;
}

Jul 17 '05 #7
"Garp" <ga***@no7.blueyonder.co.uk> wrote in news:uy_rc.141$eK7.1326235
@news-text.cableinet.net:
Hey, it's PHP. ;-)


hehe, 'A' for effort
Jul 17 '05 #8
RonS <ro**********@SPAMtds.net> wrote in
news:40**********@newspeer2.tds.net:
I've got an app that displays a months worth of data from a database
in a window. When the user clicks on an entry in this window I open a
separate small editing window for just that days data. I know I can
have a separate button for the user to close the window with
Javascript (which is the way it works now), but would rather have the
window 'automatically' close when the user submits the changes.


thats still javascript. in the 'action' part of the form, put the close
statement.

action="javascript::window.close()"

(I think I got that right)
Jul 17 '05 #9
RonS <ro**********@SPAMtds.net> writes:
I've got an app that displays a months worth of data from a database
in a window. When the user clicks on an entry in this window I open
a separate small editing window for just that days data. I know I
can have a separate button for the user to close the window with
Javascript (which is the way it works now), but would rather have
the window 'automatically' close when the user submits the changes.


Instead of trying to solve this on the server-side (where it is
impossible or at least rather difficult) couldn't you have PHP
generate JavaScript the page shown in the main window, and then when
the user submits the data, this JavaScript will check for changes.
The sub window could then be closed by this JavaScript code.

--
Martin Geisler My GnuPG Key: 0xF7F6B57B

PHP EXIF Library | PhpWeather | PhpShell
http://pel.sf.net/ | http://phpweather.net/ | http://gimpster.com/
Read/write EXIF data | Show current weather | A shell in a browser
Jul 17 '05 #10
Martin Geisler wrote:
RonS <ro**********@SPAMtds.net> writes:

I've got an app that displays a months worth of data from a database
in a window. When the user clicks on an entry in this window I open
a separate small editing window for just that days data. I know I
can have a separate button for the user to close the window with
Javascript (which is the way it works now), but would rather have
the window 'automatically' close when the user submits the changes.

Instead of trying to solve this on the server-side (where it is
impossible or at least rather difficult) couldn't you have PHP
generate JavaScript the page shown in the main window, and then when
the user submits the data, this JavaScript will check for changes.
The sub window could then be closed by this JavaScript code.


Martin ... of course that's it! As usual, it's very simple once you see it. I
just couldn't seem to come up with this. I had never closed a window other than
the current window in Javascript before now.

Thanks so much.
Ron
Jul 17 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by olga p. | last post: by
9 posts views Thread by Graham | last post: by
1 post views Thread by Sileesh | last post: by
3 posts views Thread by Vishal | last post: by
7 posts views Thread by MichaelK | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.