Hi friends
I want to perform the following actions.
1.I want a script to run when the user closes the window either by pressing ALt+F4 or pressing the X at the top right corner.
(actually i want a php system fn to run when the abv action takes place.)
2.I used anchor text in my site .I want the users to open the link in the same window not allowing them to open in new window which they do either by pressing shif+Mouseclick or right click and choose open in new window option.Can anyone help me.
thanx in advance for ur suggestions.
bye
Need Javascript
Moderator: General Moderators
- EvilWalrus
- Site Admin
- Posts: 209
- Joined: Thu Apr 18, 2002 3:21 pm
- Location: Springmont, PA USA
If I understood you right, use "<body onUnload='mySubmitFunction()'>" so that Javascript would transmit data to the server (i.e. PHP).
For part 2 of your question: I don't quite see how that ties in with part 1 - do you want the page to open in the window that was just closed? If so: sorry, mate, impossible.
If you just want to prevent someone from changing the "target='..'" in your <a href=>" use a form-button with an onClick-event.
Not sure if that is entirely what you were looking for...
For part 2 of your question: I don't quite see how that ties in with part 1 - do you want the page to open in the window that was just closed? If so: sorry, mate, impossible.
If you just want to prevent someone from changing the "target='..'" in your <a href=>" use a form-button with an onClick-event.
Not sure if that is entirely what you were looking for...
Re
Hi
I clarify u.I want a PHP system function to be called when the user performs the following actions only.
He closes the window either by pressing X or presing Alt+F4.Unload fn will be called everytime i move from that page to anyother page.Inthat case i dont want to call system fn since im not out of my session.Hope i made u clear or else revert me back.Bye
Thanx in adv for ur suggestions
I clarify u.I want a PHP system function to be called when the user performs the following actions only.
He closes the window either by pressing X or presing Alt+F4.Unload fn will be called everytime i move from that page to anyother page.Inthat case i dont want to call system fn since im not out of my session.Hope i made u clear or else revert me back.Bye
Thanx in adv for ur suggestions
patrikG wrote:If I understood you right, use "<body onUnload='mySubmitFunction()'>" so that Javascript would transmit data to the server (i.e. PHP).
For part 2 of your question: I don't quite see how that ties in with part 1 - do you want the page to open in the window that was just closed? If so: sorry, mate, impossible.
If you just want to prevent someone from changing the "target='..'" in your <a href=>" use a form-button with an onClick-event.
Not sure if that is entirely what you were looking for...
You can check whether a window Javascript has opened is still open.
With onUnload in the child-window that calls the check-function in the parent-window it's probably as close as you can get to what you want.
With onUnload in the child-window that calls the check-function in the parent-window it's probably as close as you can get to what you want.
Code: Select all
<html><head><title>Test</title>
<script type="text/javascript">
<!--
var myWin = window.open("test.html", "2nd window");
function CheckOpen()
{
if(myWin.closed == true) alert("Window has been closed");
else alert("Window still open");
}
//-->
</script>
</head><body>
<a href="javascript:CheckOpen()">Close Window?</a>
</body></html>