Havde næsten glemt dig... ;-)
Vi har diskutteret problemet andetsteds. Se om du kan få noget ud af dette:
Hi...
Is it possible to trigger an event in javascript (similar to onUnload) only when the browser is closed or the user navigates offsite (clicks a link or a bookmark) but NOT when a user moves on to another page within the same site?
Comment :
Only by using a REALLY ugly hack that measures the size of the browser onUnload.
<SCRIPT LANGUAGE="JavaScript">
<!--
function RorC() {
var top=self.screenTop;
if (top>9000)
{alert('window was closed')}
else
{alert('window was Refreshed')}
}
//-->
</SCRIPT>
</HEAD>
<BODY onunload="java script:if (document.all){RorC()} else {var top=window.outerWidth;if
(top==0) {opener.alert('window was closed')} else {opener.alert('window was Refreshed')}}">
Accepted Answer :
And here is the leave or stay code
<body onLoad="leaving=true" onUnload="if (leaving) window.open('
http://www.DIT_SITE.DK/farvel.html,'_blank')">
<a href="stay.html" onClick="leaving=false">Stay</a>
<a href="
http://www.ANDET_SITE.DK">Leave</a>Comment :
Ahh thats great
So, for my form submit, would I use an OnSubmit for the form or an OnClick for the form button to set leaving=false?
Comment :
<form onSubmit="leaving=false">
or if you need to validate too:
<script>
function validate(theForm) {
.
.
.
leaving=false
return true
}
<form onSubmit="return validate(this)">
Nærmere tror jeg ikke vi kommer det !
Mvh. Molokyle