From default Colorization to grayscale. [mutual conversion]

Source: Internet
Author: User

From default Colorization to grayscale.

<Div id = "friendbox">
<A href = ""> </a>
<A href = ""> </a>
<A href = ""> </a>
<A href = ""> </a>
</Div>

<SCRIPT>
(Function (){
VaR IMGs = Document. getelementbyid ("friendbox"). getelementsbytagname ("IMG"), imgs_length = IMGs. length, I = 0;
VaR imghover = function (thenode, thesrc ){
Return function (e ){
VaR Reg = /(? : \. Jpg | \. gif | \. PNG) $/I;
VaR result = thesrc. Match (REG );
VaR resultsrc = "_ gray" + result;
VaR newsrc = thesrc. Replace (result, resultsrc );
Thenode. setattribute ("src", newsrc );
}
};
VaR imgout = function (thenode, thesrc ){
Return function (e ){
Thenode. setattribute ("src", thesrc );
}
};

For (I = 0; I VaR imgsrc = IMGs [I]. getattribute ("src ");
IMGs [I]. onmouseover = imghover (IMGs [I], imgsrc );
IMGs [I]. onmouseout = imgout (IMGs [I], imgsrc );
}
})();
</SCRIPT>

From grayscale by default to colorization.

<Div id = "friendbox" class = "friendbox Clearfix">
<A href = ""> </a>
<A href = ""> </a>
<A href = ""> </a>
<A href = ""> </a>
<A class = "last" href = ""> </a>
</Div>

<SCRIPT>
(Function (){
VaR IMGs = Document. getelementbyid ("friendbox"). getelementsbytagname ("IMG"), imgs_length = IMGs. length, I = 0;
VaR imghover = function (thenode, thesrc ){
Return function (e ){
VaR newsrc = thesrc. Replace (/_ gray /,"");
Thenode. setattribute ("src", newsrc );
}
};
VaR imgout = function (thenode, thesrc ){
Return function (e ){
Thenode. setattribute ("src", thesrc );
}
};

For (I = 0; I VaR imgsrc = IMGs [I]. getattribute ("src ");
IMGs [I]. onmouseover = imghover (IMGs [I], imgsrc );
IMGs [I]. onmouseout = imgout (IMGs [I], imgsrc );
}
})();
</SCRIPT>

From default Colorization to grayscale. [mutual conversion]

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.