Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onunload event not getting triggered for UK users

Status
Not open for further replies.

edge27

Programmer
Jun 23, 2003
12
US
Hello,

I have an ASP page that uses javascript to open up another window when that first page is closed or user goes to another link. The javascript runs when the onunload event is triggered. It seems to run fine especially for our local U.S. users. But users in the UK are not getting the onunload event triggered. They use a proxy server but we list our URL as an exception. And their cache is set to check for a new page everytime. They are not receiving any signs of a javascript error. What else can I check?
 
i would start off by making a simple test page for them:

<html>
<head>
<title>unload test</title>
</head>
<body onunload=&quot;alert('unload fired');&quot;>
close this window
</body>
</html>

=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Thanks for the reply,

I have tried a simple page like that...the user does get an alert for the onload and onunload events in the case of the simple page.
 
There is a lot more to it than this but here is function and the event...Thanks Jeff

<script language=&quot;javascript&quot;>
function resetApp()
{

var pId, sId
sId = document.frmAddStatus.uId.value
pId = document.frmAddStatus.pId.value
window.open(&quot;TTAddReset.asp?pId=&quot;+pId+&quot;&sId=&quot;+sId)

}
</script>


<HTML>
<head>
<meta NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;TTstyle.css&quot;>
<script language=&quot;JavaScript&quot; src=&quot;FormValidation.js&quot;></script>
<script language=&quot;JavaScript&quot; src=&quot;ts_picker.js&quot;></script>
</head>
<BODY onunload=&quot;resetApp()&quot;>
 
have you tried an alert in resetApp() to see if the uk users get it?

<script language=&quot;javascript&quot;>
function resetApp()
{
alert(&quot;unload&quot;)
var pId, sId
sId = document.frmAddStatus.uId.value
pId = document.frmAddStatus.pId.value
window.open(&quot;TTAddReset.asp?pId=&quot;+pId+&quot;&sId=&quot;+sId)

}
</script>




=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
I have tried this and he gets both alerts.

<html>
<body onLoad = &quot;alert('Loaded Again...')&quot; onUnLoad = alert(&quot;UnloadedAgain...&quot;)>
<html>

I have noticed in my own environment and wonder if it's related to why UK user dont see any error that:

When I view the page in the IE browser, no error is returned. If I go to Internet options and uncheck &quot;Display Scipt Error&quot; and check &quot;Display a notification about every script Error&quot; I receive the javascript error. Here's the tricky part. If I close my browser and open the page again, I again get no error. Then I open my Internet Options (still with the new setting shown) and simply click OK. Now if I refresh my page I get the Javascript error. Its as if I have to remind the Internet Options of my setting everytime. Some of my users here with the older versions or service packs of IE don't have this problem and some do. My IE version is 6.0.2800.1106 Update version SP1.
 
what error?

and try it with the alert actually in resetApp(), not as you described above.

<script language=&quot;javascript&quot;>
function resetApp()
{
alert(&quot;unload&quot;)
var pId, sId
sId = document.frmAddStatus.uId.value
pId = document.frmAddStatus.pId.value
window.open(&quot;TTAddReset.asp?pId=&quot;+pId+&quot;&sId=&quot;+sId)

}
</script>


=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Wow...thanks for the almost real time response!

I will try the alert as you describe tomorrow since this user is in the UK.

Sorry...I cut off the beginning of my other IE scripting error question when I copied it from another posting site. What I did in resetApp function was just removed the &quot;o&quot; from the word &quot;document&quot;. Im thinking this guy is encountering a script error since the events seem to get triggered. Thats when I discovered how my script debugging is misbehaving as noted above.
 
At one time, javascript was case-sensitive - onload was not the same as onLoad. I notice that in your second example <body onLoad = &quot;alert('Loaded Again...')&quot; onUnLoad = alert(&quot;UnloadedAgain...&quot;)> the onload & onunload event handlers are correctly capitalized but your first example isn't. Could this be the problem?

There's always a better way...
 
tviman,

yes, the javascript event handlers are case sensitive, and they are all lowercase.

// correct
window.onload = foo;
// incorrect
window.onLoad = foo;

event handler attributes in html tags are not case sensitive.
correct:
<body onload=&quot;foo();&quot;>
also correct:
<body oNlOaD=&quot;foo();&quot;>



=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Jemminger,

Thanks for setting me straight.

I wonder if UK ISP's are to blame for edge27's troubles. Could it be that they're using some sort of pop-up/pop-under blocking software?

There's always a better way...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top