是否有可能告诉我window.location.href在历史记录中返回2页并重新加载被调用的页面?
我只是设法让它像这样工作:
<script type="text/javascript">
window.location.href = "http://www.google.com/";
</script>
Run Code Online (Sandbox Code Playgroud)
我尝试使用该命令的所有其他内容history.back(-2)在我的情况下都不起作用.
我制作了一个test.html文档来测试脚本.不知怎的,它不起作用,我无法理解为什么没有发生任何事情.脚本在-tags中并用-tag包装,而css也有-tags.它为什么不起作用?这是代码
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
</script>
<script>
$('#menu li a').on('click', function() {
$('li a.current').removeClass('current');
$(this).addClass('current');
});
</script>
<style>
.current {
text-decoration: underline;
}
ul {
list-style-type: none;
}
a {
text-decoration: none;
}
</style>
</head>
<body>
<div id="menu">
<ul>
<li><a id="about-link" class="current" href="#">ABOUT</a></li>
<li><a id="events-link" href="#">EVENTS</a></li>
<li><a id="reviews-link" href="#">REVIEWS</a></li>
<li><a id="contact-link" href="#">CONTACT</a></li>
</ul>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)