Re: Calling a javascript using header();
| From: | Lars Torben Wilson | Date: | Wed, 13 Sep 2000 09:51:27 +0000 |
| Subject: | Re: Calling a javascript using header(); | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-16531@lists.php.net to get a copy of this message | ||
Jesper Hess Nielsen writes:
> Hi all
>
> I'm trying to execute a piece of javascript code (to close the
> current window after processing some user input) using the following
> code :
>
> header("Location: javascript:window.close();");
>
> what is the correct way of doing this, cause I certainly can't get
> it to work right for me??
>
> /Jesper
Just output the Javascript text to call that function. Quick example:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML-3.2//EN">
<html>
<head>
<title></title>
</head>
<body>
<?php
error_reporting(E_ALL);
echo "Sleeping for 5 seconds...<br>\n";
flush();
sleep(5);
?>
<script>
window.close();
</script>
</body>
</html>
Since Javascript is text just like HTML, you just output it to the
browser, and it'll behave normally once it gets there.
--
+----------------------------------------------------------------+
|Torben Wilson <torben@php.net> Netmill iTech|
|http://www.coastnet.com/~torben http://www.netmill.fi|
|Ph: 1 250 383-9735 torben@netmill.fi|
+----------------------------------------------------------------+