JavaScript dynamic change img src attribute picture does not show solution _ image effect

Source: Internet
Author: User
First of all, the occurrence of this bug, the page has
Copy Code code as follows:

<a href= "javascript:void (0)" onclick= "document.getElementById (' current '). src= ' images/001.jpg '; >
So a label, onclick in the JS code is to change the ID of the IMG tag of the SRC attribute, to achieve the dynamic switch picture effect. But unfortunately: IE is dynamically changing the path of the picture, but the picture is not displayed, the right button "display picture" to see the change after the picture, I do not know what the reason, but it is said to be <a href= "javascript:void (0)" > or <a href= "#" > Using a label like this does not prevent a tag from finally triggering a behavior, cause IE6 will mistakenly think that the page is refreshed or redirected, and that all current connections are interrupted, so that the load of the new picture is aborted (not true or false), whether the reason is true or false, Let's talk about the solution here.

Easy way to fix it:
Copy Code code as follows:

<a href= "javascript:void (0)" onclick= "document.getElementById (' current '). src= ' images/001.jpg '; return false; >;


is to add return false after the code;

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.