JavaScript Techies??


Status
Not open for further replies.

togu

Senior Member
Jul 11, 2002
5,290
0
0
50
@ D08
www.tommygui.com
Yo all, some help needed... :(

Wondering if it's possible to let a window load a pl or php script, then close the browser window, whenever the user click on the X button on the top right corner.

The flow should be something like this,

<script>
function leave() {

some functions to load "byebye.pl"
}
</script>
</head>
<body onUnload="leave()">

or any other ways of doing it?


A million thanks.

:)
 

here's a simple script I use for my co. intranet (originally used for ASP page).

<script>
function leave() {
window.open('byebyeTOGU.php','window_handle','width=50,height=50');
}
</script>
</head>
<body onUnload="leave()">


This should pop up the file byebyeTOGU.php whenever the document window is closed or user navigates to another site.

In the php file, you should do whatever you need to do in PHP script and call the javascript window.close() function when you are done, to close this popup window.

not too sure how you will do that in PHP but this works in ASP. :)
 

You probably want something like this .... ?

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function leave ()
{
window.open('index.html');
}
//-->
</SCRIPT>
<BODY OnUnload=leave();>
</BODY>
</HTML>
 

Originally posted by petaflopz
here's a simple script I use for my co. intranet (originally used for ASP page).

<script>
function leave() {
window.open('byebyeTOGU.php','window_handle','width=50,height=50');
}
</script>
</head>
<body onUnload="leave()">


This should pop up the file byebyeTOGU.php whenever the document window is closed or user navigates to another site.

In the php file, you should do whatever you need to do in PHP script and call the javascript window.close() function when you are done, to close this popup window.

not too sure how you will do that in PHP but this works in ASP. :)

no difference between PHP and ASP as we're talking about pure javascript here ;)
 

:gbounce:

Coolio! Thanks Guys, will try it when I'm back to office. :)

:gbounce:
 

Status
Not open for further replies.