javascript window.location 和 IE 会话变量丢失
我在使用 javascript 时使用 Internet Explorer (IE 9) 时丢失会话变量 窗口定位函数。
我注意到之前的页面和之后的页面显示相同的会话ID;但是 即使会话 ID 相同,当发生重定向时,会话变量也会丢失。 我还注意到,这种情况在 IE 中并不是每次都会发生,只是偶尔发生(随机)。 使用 Chrome 时我没有遇到任何问题。
实时应用程序在这里:http://apps.facebook.com/zabeachwatch/ (当您观看视频时,它应该超时并在一段时间过后将您重定向回来。 如果您到达注册页面,则意味着会话变量已丢失。通过 facebook 访问页面时不应发生这种情况)
是否有其他方法可以重定向计时器事件?
下面是导致重定向的代码片段。(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 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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现“window.location.href”在 INTERNET EXPLORER 中无法按预期工作
8 和 9。
对我有用的另一种方法是将元标记“刷新”与其他一些方法一起使用
逻辑得到相同的结果。就我而言,这是一个简单的超时函数。
祝
你好运
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