How to use JavaScript to obtain the color selector function provided by the system (Figure) _ javascript skills

Source: Internet
Author: User
JavaScript obtains the color selector function that comes with the system. This function is for IE browsers. If you want to use code with better compatibility, you can view articles related to the script house. Effect:

The following code gets the color selector that comes with the system:

Script function $ (obj) {return document. getElementById (obj);} function pickColor () {if (! Window. isIE) return; var sColor = $ ('dlghelper '). chooseColorDlg (); var color = sColor. toString (16); while (color. length <6) color = "0" + color; window. color = color; color = "#" + color; $ ('P _ color '). style. backgroundColor = color; $ ('P _ color '). value = color;} var isIE = (document. all & window. activeXObject )? True: false; script <OBJECT id = "dlgHelper" CLASSID = "clsid: 3050f819-98b5-11cf-bb82-00aa00bdce0b "WIDTH =" 0px "HEIGHT =" 0px "> </OBJECT> <input class =" inputtext "style = 'width: 50px; cursor: hand; 10px; background-color: #000000; color: # ffffff; 'id = 'P _ color' value = "#000000"/> <input type = "button" value = 'retrieve color' onclick = "pickColor ()">
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]


Advantage: less code
Disadvantage: it can only be used in IE.
Related Article

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.