Home  >  Article  >  Web Front-end  >  Solution to window.location.href jump failure under IE_javascript skills

Solution to window.location.href jump failure under IE_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:54:131488browse
Copy code The code is as follows:

GoNext
$("a").click(function(){
window.location.href = "xxx.html";
})

The code is as above. Under IE, especially in IE6, after clicking the hyperlink, the browser does not jump.

The reason may be the event behavior blocked by javascript:void(0) in href. The solution is as follows:

1. Add return false to the onclick event to prevent bubbling:
Copy code The code is as follows:

$("a").click(function(){
window.location.href = "xxx.html";
reutrn false;
})

2. Delay 100 milliseconds
Copy code The code is as follows:

$("a").click(function(){
setTimeout(function(){
window.location.href = "xxx.html";
},100);
})
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn