Forum Moderators: open

Message Too Old, No Replies

IE7 not calling body onload="myfunction();return true;

         

stacey11

11:13 pm on Oct 23, 2007 (gmt 0)

10+ Year Member



We have a web application that has been working fine with Firefox and IE6 that has ceased to function correctly in IE7. Our application uses a frameset, and if the client has a userlimit on their account, the current sessions are checked to see if opening another would violate their use limit. If so, the request is redirected to a jsp that includes the following code:

<head>
<script type="text/javascript" language="javascript">
function breakout() {
if (top.location.href!= location.href) {
top.location.href = location.href;
}
}
</script>
</head>
<body onload="breakout();return true">
....

but IE7 is apparently ignoring the call and the frameset gets corrupted.

Any ideas?

lavazza

1:43 am on Oct 24, 2007 (gmt 0)

10+ Year Member



Try moving the RETURN=TRUE statement AND adding a SEMI-COLON after it

Also, you can (should, but don't really NEED to) delete LANGUAGE="JAVASCRIPT"

<head>
<script type="text/javascript">
function breakout() {
if (top.location.href!= location.href) {
top.location.href = location.href;
}
return true;
}
</script>
</head>

<body onload="breakout();">

Achernar

10:19 am on Oct 24, 2007 (gmt 0)

10+ Year Member Top Contributors Of The Month



With

if (top.location.href!= location.href) {
top.location.href = location.href;
}

the problem is that if "top.location" is not in the same domain as the frame, the script will not have the permission to read it, likewise comparing, and will stop with an error.

Try this instead:

if (window!=top) top.location=window.location;

[edited by: Achernar at 10:20 am (utc) on Oct. 24, 2007]