Solution and recommended code for non-redirection of location. href in IE6

Source: Internet
Author: User

The following content is a post:

Code

Copy codeThe Code is as follows: <script type = "text/javascript">
Function goUrl (x)
{
Window. location. href = x;
}
</Script>
<A href = "javascript:;" onclick = "javascript: goUrl ('HTTP: // www.baidu.com ');"> jump 1 </a>
<A href = "javascript: void (0);" onclick = "javascript: goUrl ('HTTP: // www.jb51.net ');"> jump 2 </a>
<A href = "javascript: void (0);" onclick = "javascript: goUrl ('HTTP: // s.jb51.net '); return false;"> jump 3 </a>
<A href = "#" onclick = "javascript: goUrl ('HTTP: // adm.baidu.com ');"> jump to 4 </a>
<A href = "###" onclick = "javascript: goUrl ('HTTP: // tools.jb51.net');"> jump to 5 </a>

Test Environment IE6, IE7, and Firefox 3.
The redirection 1 and 2 are invalid in IE6, and both 3, 4, and 5 pass the tests in IE6, IE7, and Firefox3.01 ,.
Jump to 4 and 5 is the most concise.
The key lies in the href attribute of <a>. For empty links, use "#","###".
In order not to return to the top of the page.
"####" Is recommended for empty links "###".

I used the third method, and added return false to the end. In this way, IE6, IE7, and FF3 all passed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.