简体   繁体   English

history.forward()在浏览器中不受影响

[英]history.forward() does not affect in browser

I wrote in the body tag of the jsp page like : 我在jsp页面的body标签中写道:

onload = "history.forward()"

This code is affected in my browser (Internet Explore) but it is not affected in update version of browser and some Internet Explore. 此代码在我的浏览器(Internet Explorer)中受到影响,但在浏览器的更新版本和某些Internet Explorer中不受影响。 I also checked "enable javascript" in the mozilla like : 我还在mozilla中选中了“启用javascript”:

Tools ---> Options ---> Content tab --->  Enable Javascript

But it is not ok. 但这不行。 I would like to know whether this problem is because of browser version or browser setting. 我想知道此问题是由于浏览器版本还是浏览器设置引起的。 How will I do to be affected for the following code : 以下代码将如何影响我:

onload = "history.forward()"

你应该试试:

window.history.forward();

Try history.go(1) , this should work. 尝试一下history.go(1) ,这应该可以工作。 or window.history.go(1) window.history.go(1)

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2   /jquery.min.js"></script>
<script>
$(document).ready(function(){
    window.history.forward();
});
</script>
</head>
</html>

Use this method. 使用此方法。 It is working,but it have used jQuery. 它正在运行,但已使用jQuery。

Try this code 试试这个代码

<body onload="onLoad();" onpageshow="if (event.persisted) onLoad();"> 

because Firefox uses in-memory caching for entire Web pages, including their JavaScript states, for a single browser session. 因为Firefox在单个浏览器会话中对整个网页(包括JavaScript状态)使用内存缓存。 Going backward and forward between visited pages requires no page loading and the JavaScript states are preserved. 在访问的页面之间来回移动不需要加载页面,并且会保留JavaScript状态。

Click here for your reference 点击这里供您参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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