简体   繁体   中英

javascript window.location and IE session variables are lost

I am loosing session variables when using Internet Explorer (IE 9) when using the javascript window.location function.

I have noticed that the page before and the page after displays the same session ID; but the session variables are lost when the redirect occurs even if the session ids are the same. I have also noticed that this does not happen each and every time in IE, only some times(Random). With Chrome I experience no problems.

The live application is here: http://apps.facebook.com/zabeachwatch/ (When you view the Video it should time-out and redirect you back after some time has elapsed. If you land up on a registration page, this means that the session variables have been lost. This should not happen when accessing the page via facebook)

Is there perhaps some other way to redirect on a timer event?

Below is a snippet that causes the redirect.(window.location...)

<%
String cat = request.getParameter("cat");
String back_url = "CameraList.jsp?cat=" + cat;
back_url = response.encodeURL(back_url);
%>



<script type="text/javascript" language="javascript">
<!--
 var winW = 630, winH = 460;

function delayer(){
var s = "<%=back_url%>";
window.location.href = s;
return true;
}

<body id="images" style="background: rgb(197,204,211) 
 url(images/stripes.png);" onload="setTimeout('delayer()', 30000);

I have found that the "window.location.href" does not work as expected with INTERNET EXPLORER 8 and 9.

An alternative approach that works for me is to use the meta tag "refresh" together with some other logic to get the same result. In my case it was a simple timeout function.

<meta http-equiv="refresh" content="60"/>

Good Luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM