Home  >  Article  >  Web Front-end  >  Solution to invalid window.location.href in IE6 browser_javascript skills

Solution to invalid window.location.href in IE6 browser_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:30:571942browse

The example in this article describes the solution to the invalid window.location.href in IE6 browser. Share it with everyone for your reference. The specific method is as follows:

Window.location.href is the jump function in js. Many people will find that window.location.href cannot jump in IE6. Let me introduce the reasons and solutions to you.

The problem code is as follows:

Copy code The code is as follows:
Click to jump
<script> <br> test = function(){ <br> window.location.href = "http://www.jb51.net"; <br> } <br> </script>


The correct code is as follows:
Copy code The code is as follows:
Click to jump
<script> <br> test = function(){ <br> window.location.href = "http://www.jb51.net"; <br> } <br> </script>


Reason:
Return false so that the browser's events will not continue to bubble out and trigger the browser's default event

Summary
The principle is not that window.location.href is incompatible, but that our return false later prevents the jump.

I hope this article will be helpful to everyone’s JavaScript programming design.

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