后退按钮失败后window.location.replace(HREF); [英] Back button fails after window.location.replace(href);
问题描述
function allHot(element){
$(element)
.click(
function (){
var href = $(this).find('a')。attr('href');
window.location.replace(href);
})
.hover(
function(){
$(this).css({'text-shadow':'0px 1px 0px#D6D6D6'});
} ,
function(){
$(this).css({'text-shadow':'none'});
}
);
}
功能很好。而不是点击更多按钮,用户可以点击容器上的任何地方,并正确重定向。
然而,如果用户重定向后点击后退按钮,浏览器返回两个步骤而不是一个,因为它应该。简单的方案来更好的描述:
lockquote
第1页 - >第2页
第2页[用户点击allHot容器] - > allHot重定向到第3页
Page3 [用户点击浏览器后退按钮] - > Page1
这是我正在处理的网站的主要错误。我真的没有办法阻止它。在Firefox,Chrome和Opera上测试错误。 b
$ b
测试Opera没有javascript模式。如果JavaScript被禁用,则不会发生问题。
感谢您提供任何线索或解决方案。 replace
,使用下面的代码:
window.location.href =''
I made simple function which makes all container behave like link ("a" element).
function allHot(element){
$(element)
.click(
function(){
var href = $(this).find('a').attr('href');
window.location.replace(href);
})
.hover(
function(){
$(this).css({'text-shadow' : '0px 1px 0px #D6D6D6'});
},
function(){
$(this).css({'text-shadow' : 'none'});
}
);
}
Function works great. Instead of clicking the "more" button, user can click everywhere on container and is properly redirected.
However, if user after redirection clicks back button, browser goes back two steps instead of one as it should. What's more weird, history looks OK.
Simple scheme to better description:
Page1 -> Page2
Page2 [user clicks on "allHot" container] -> allHot redirects to Page3
Page3 [user clicks on browser back button] -> Page1
This is major bug for website I'm working on right now. I don't really have a clue to prevent it. Bug tested on Firefox, Chrome and Opera.
Tested also on Opera "no javascript mode". If javascript is disabled issue doesn't occure.
Thanks in advance for any clue or solution.
Instead of using replace
, use the following:
window.location.href = ''
这篇关于后退按钮失败后window.location.replace(HREF);的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!