Colour selector Color Picker,ie,firefox,opera,safar_javascript Tips

Source: Internet
Author: User
Tags visibility

From: Color selector colorpicker
http://jscolor.com/
http://dematte.at/colorPicker/
http://www.free-color-picker.com/color-picker-samples.php
http://www.nogray.com/color_picker.php
http://www.mattkruse.com/javascript/colorpicker/

Colorpicker2.js Code
Copy Code code as follows:

// ===================================================================
Author:matt Kruse <matt@mattkruse.com>
www:http://www.mattkruse.com/
//
Notice:you may use this code for any purpose, commercial or
Private, without any further permission from the author. May
Remove this notice to your final code if you wish however it is
Appreciated by the author if in least my web site address is kept.
//
You could *not* re-distribute this code in any way except through its
Use. That means, your can include it in your product, or your web
Site, or any other form where the code is actually being used. You
May isn't put the plain JavaScript up on your site for download or
Include it in your JavaScript libraries for download.
If you are wish to share this code with others, please just point them
to the URL instead.
Please don't link directly to me. js files from your site. Copy
The files to your server and use them there. Thank you.
// ===================================================================

/* SOURCE FILE:AnchorPosition.js * *
function Getanchorposition (anchorname) {var usewindow=false;var coordinates=new Object (); var x=0,y=0;var use_gebi= False, Use_css=false, Use_layers=false;if (document.getElementById) {use_gebi=true;} else if (document.all) {use_css=true} else if (document.layers) {use_layers=true} if (Use_gebi && document.all) {x=anchorposition_getpageoffsetleft (document.all[anchorname]); y= Anchorposition_getpageoffsettop (Document.all[anchorname]); else if (Use_gebi) {var o=document.getelementbyid (anchorname); X=anchorposition_getpageoffsetleft (o); y= Anchorposition_getpageoffsettop (o);} else if (use_css) {x=anchorposition_getpageoffsetleft (document.all[anchorname]); y=anchorposition_getpageoffsettop (Document.all[anchorname]);} else if (use_layers) {var found=0;for (var i=0;i<document.anchors.length;i++) {if (document.anchors[i].name== Anchorname) {Found=1;break}} if (found==0) {Coordinates.x=0;coordinates.y=0;return coordinates;} X=DOCUMENT.ANCHORS[I].X;Y=DOCUMENT.ANCHORS[I].Y;} Else{coordinates.x=0;coordinates.y=0;returncoordinates;} Coordinates.x=x;coordinates.y=y;return coordinates;}
function Getanchorwindowposition (anchorname) {var coordinates=getanchorposition (anchorname); var x=0;var y=0;if ( document.getElementById) {if (isNaN (Window.screenx)) {x=coordinates.x-document.body.scrollleft+window.screenleft; Y=coordinates.y-document.body.scrolltop+window.screentop;} else{x=coordinates.x+window.screenx+ (window.outerwidth-window.innerwidth)-window.pagexoffset;y=coordinates.y+ window.screeny+ (Window.outerheight-24-window.innerheight)-window.pageyoffset}} else if (document.all) {x=coordinates.x-document.body.scrollleft+window.screenleft;y= Coordinates.y-document.body.scrolltop+window.screentop;} else if (document.layers) {x=coordinates.x+window.screenx+ (window.outerwidth-window.innerwidth)- window.pagexoffset;y=coordinates.y+window.screeny+ (Window.outerheight-24-window.innerheight)- Window.pageyoffset;} Coordinates.x=x;coordinates.y=y;return coordinates;}
function Anchorposition_getpageoffsetleft (EL) {var ol=el.offsetleft;while (el=el.offsetparent)!= null) {ol + = El.offsetleft;} return ol;}
function Anchorposition_getwindowoffsetleft (EL) {return Anchorposition_getpageoffsetleft (EL)- Document.body.scrollLeft;}
function Anchorposition_getpageoffsettop (EL) {var ot=el.offsettop;while (el=el.offsetparent)!= null) {ot + = El.offsettop;} return ot;}
function Anchorposition_getwindowoffsettop (EL) {return anchorposition_getpageoffsettop (EL)- Document.body.scrollTop;}

/* SOURCE FILE:PopupWindow.js * *
function Popupwindow_getxyposition (anchorname) {var coordinates;if (This.type = = "Window") {coordinates = Getanchorwindowposition (anchorname);} Else{coordinates = Getanchorposition (anchorname);} this.x = Coordinates.x;this.y = Coordinates.y;}
function Popupwindow_setsize (width,height) {this.width = Width;this.height = height;}
function Popupwindow_populate (contents) {this.contents = contents;this.populated = false;}
function Popupwindow_seturl (URL) {this.url = URL;}
function Popupwindow_setwindowproperties (props) {this.windowproperties = props;}
function Popupwindow_refresh () {if (this.divname!= null) {if (This.use_gebi) {document.getElementById (this.divname). InnerHTML = this.contents;} else if (this.use_css) {document.all[this.divname].innerhtml = this.contents;} else if (this.use_layers) {var d = document.layers[this.divname];d. Document.open ();d. Document.writeln (this.contents) ;d. Document.close ();}} Else{if (This.popupwindow!= null &&!this.popupwindow.closed) {if (this.url!= "") { This.popupwindow.location.href=this.url;} Else{this.popupwindow.document.open (); This.popupWindow.document.writeln (this.contents); This.popupWindow.document.close ();} This.popupWindow.focus ();}}
function Popupwindow_showpopup (anchorname) {this.getxyposition (anchorname); This.x + = This.offsetx;this.y = This.offsety;if (!this.populated && (this.contents!= "")) {this.populated = True;this.refresh ();} if (this.divname!= null) {if (This.use_gebi) {document.getElementById (this.divname). Style.left = this.x + "px"; document.getElementById (this.divname). Style.top = This.y;document.getelementbyid (this.divname). style.visibility = "Visible";} else if (this.use_css) {document.all[this.divname].style.left = This.x;document.all[this.divname].style.top = This.y; document.all[this.divname].style.visibility = "visible";} else if (this.use_layers) {document.layers[this.divname].left = This.x;document.layers[this.divname].top = This.y; document.layers[this.divname].visibility = "visible";}} Else{if (This.popupwindow = = NULL | | | this.popupWindow.closed) {if (this.x<0) {this.x=0;} if (this.y<0) {this.y=0;} if (screen && screen.availheight) {if (This.y + this.height) > screen.availheight) {this.y = ScreEn.availheight-this.height}} if (screen && screen.availwidth) {if (this.x + this.width) > screen.availwidth) {this.x = Screen.availwidth- This.width}} var Avoidaboutblank = Window.opera | | (Document.layers &&!navigator.mimetypes[' *]) | | Navigator.vendor = ' KDE ' | | (Document.childnodes &&!document.all &&!navigator.taintenabled); This.popupwindow = window.open ( Avoidaboutblank? "": "About:blank", "Window_" +anchorname,this.windowproperties+ ", width=" +this.width+ ", height=" + this.height+ ", screenx=" +this.x+ ", left=" +this.x+ ", screeny=" +this.y+ ", top=" +this.y+ ""); This.refresh ();}
function Popupwindow_hidepopup () {if (this.divname!= null) {if (This.use_gebi) {document.getElementById (this.divname) . style.visibility = "hidden";} else if (this.use_css) {document.all[this.divname].style.visibility = "hidden";} else if (this.use_layers) {document.layers[this.divname].visibility = "hidden";}} Else{if (This.popupwindow &&!this.popupwindow.closed) {this.popupWindow.close (); this.popupwindow = null;}}}
function popupwindow_isclicked (e) {if (this.divname!= null) {if (this.use_layers) {var Clickx = E.pagex;var Clicky = E.pagey;var t = document.layers[this.divname];if (Clickx > T.left) && (Clickx < T.left+t.clip.width) & & (Clicky > T.top) && (Clicky < t.top+t.clip.height)) {return true;} Else{return false;}} else if (document.all) {var t = window.event.srcelement;while (t.parentelement!= null) {if (t.id==this.divname) {return true;} t = t.parentelement;} return false;} else if (This.use_gebi && e) {var t = e.originaltarget;while (T.parentnode!= null) {if (t.id==this.divname) {return true;} t = T.parentnode;} return false;} return false;} return false;}
function popupwindow_hideifnotclicked (e) {if (this.autohideenabled &&!this.isclicked (e)) {This.hidepopup ();}}
function Popupwindow_autohide () {this.autohideenabled = true;}
function Popupwindow_hidepopupwindows (e) {for (Var i=0;i<popupwindowobjects.length;i++) {if (popupwindowobjects[i ]!= null) {var p = popupwindowobjects[i];p. hideifnotclicked (e);}}}
function Popupwindow_attachlistener () {if (document.layers) {document.captureevents (event.mouseup);} Window.popupwindowoldeventlistener = document.onmouseup;if (Window.popupwindowoldeventlistener!= null) { Document.onmouseup = new Function ("Window.popupwindowoldeventlistener ()"; Popupwindow_hidepopupwindows (); ");} Else{document.onmouseup = popupwindow_hidepopupwindows;}
function Popupwindow () {if (!window.popupwindowindex) {window.popupwindowindex = 0;} if (!window.popupwindowobjects) {window.popupwindowobjects = new Array ();} if (!window.listenerattached) {window.listenerattached = true; Popupwindow_attachlistener ();} This.index = popupwindowindex++;p Opupwindowobjects[this.index] = This;this.divname = Null;this.popupwindow = null; this.width=0;this.height=0;this.populated = false;this.visible = false;this.autohideenabled = False;this.contents = "" This.url= ""; this.windowproperties= "toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable, Alwaysraised,dependent,titlebar=no "; if (arguments.length>0) {this.type=" DIV "; this.divname = Arguments[0];} else{this.type= "Window";} This.use_gebi = False;this.use_css = False;this.use_layers = False;if (document.getElementById) {This.use_gebi = true;} else if (document.all) {this.use_css = true;} else if (document.layers) {this.use_layers = true;} Else{this.type = "Window";} This.offsetx = 0;this.offsety = 0;this.getxyposition = popupwindow_getxyposition;this.populate = Popupwindow_populate;this.seturl = Popupwindow_seturl; This.setwindowproperties = Popupwindow_setwindowproperties;this.refresh = Popupwindow_refresh;this.showpopup = Popupwindow_showpopup;this.hidepopup = Popupwindow_hidepopup;this.setsize = popupwindow_setsize;this.isclicked = Popupwindow_isclicked;this.autohide = popupwindow_autohide;this.hideifnotclicked = PopupWindow_hideIfNotClicked;}


/* SOURCE FILE:ColorPicker2.js * *

Colorpicker_targetinput = null;
function Colorpicker_writediv () {Document.writeln ("<div id=\" colorpickerdiv\ "style=\" Position:absolute; Visibility:hidden;\ "> </DIV>");}
function Colorpicker_show (anchorname) {this.showpopup (anchorname);}
function Colorpicker_pickcolor (color,obj) {obj.hidepopup ();p ickcolor (color);}
function Pickcolor (color) {if (colorpicker_targetinput==null) {alert ("Target Input is null, which means you either didn ' t Use the ' SELECT ' function or your have no defined your own ' pickcolor ' function to handle the picked '); return;} Colorpicker_targetinput.value = color;}
function Colorpicker_select (inputobj,linkname) {if (inputobj.type!= "text" && inputobj.type!= "hidden" & & inputobj.type!= "textarea") {alert ("Colorpicker.select:Input object passed is not a valid form Input object"); window . Colorpicker_targetinput=null;return;} Window. Colorpicker_targetinput = Inputobj;this.show (linkname);}
function Colorpicker_highlightcolor (c) {var thedoc = (arguments.length>1)? arguments[1]:window.document;var D = Thedoc.getelementbyid ("Colorpickerselectedcolor");d. Style.backgroundcolor = C;d = Thedoc.getelementbyid (" Colorpickerselectedcolorvalue ");d. InnerHTML = C;}
function ColorPicker () {var windowmode = false;if (arguments.length==0) {var divname = "Colorpickerdiv";} else if (arguments[0] = = "Window") {var divname = '; Windowmode = true;} Else{var divname = arguments[0];} if (Divname!= "") {var cp = new Popupwindow (divname);} Else{var cp = new Popupwindow (); cp.setsize (225,250);} Cp.currentvalue = "#FFFFFF"; cp.writediv = Colorpicker_writediv;cp.highlightcolor = Colorpicker_highlightcolor; Cp.show = Colorpicker_show;cp.select = Colorpicker_select;var colors = new Array ("#000000", "#000033", "#000066", "# 000099 "," #0000CC "," #0000FF "," #330000 "," #330033 "," #330066 "," #330099 "," #3300CC ",
"#3300FF", "#660000", "#660033", "#660066", "#660099", "#6600CC", "#6600FF", "#990000", "#990033", "#990066", "#990099",
"#9900CC", "#9900FF", "#CC0000", "#CC0033", "#CC0066", "#CC0099", "#CC00CC", "#CC00FF", "#FF0000", "#FF0033", "#FF0066",
"#FF0099", "#FF00CC", "#FF00FF", "#003300", "#003333", "#003366", "#003399", "#0033CC", "#0033FF", "#333300", "#333333",
"#333366", "#333399", "#3333CC", "#3333FF", "#663300", "#663333", "#663366", "#663399", "#6633CC", "#6633FF", "#993300",
"#993333", "#993366", "#993399", "#9933CC", "#9933FF", "#CC3300", "#CC3333", "#CC3366", "#CC3399", "#CC33CC", "#CC33FF",
"#FF3300", "#FF3333", "#FF3366", "#FF3399", "#FF33CC", "#FF33FF", "#006600", "#006633", "#006666", "#006699", "#0066CC",
"#0066FF", "#336600", "#336633", "#336666", "#336699", "#3366CC", "#3366FF", "#666600", "#666633", "#666666", "#666699",
"#6666CC", "#6666FF", "#996600", "#996633", "#996666", "#996699", "#9966CC", "#9966FF", "#CC6600", "#CC6633", "#CC6666",
"#CC6699", "#CC66CC", "#CC66FF", "#FF6600", "#FF6633", "#FF6666", "#FF6699", "#FF66CC", "#FF66FF", "#009900", "#009933",
"#009966", "#009999", "#0099CC", "#0099FF", "#339900", "#339933", "#339966", "#339999", "#3399CC", "#3399FF", "#669900",
"#669933", "#669966", "#669999", "#6699CC", "#6699FF", "#999900", "#999933", "#999966", "#999999", "#9999CC", "#9999FF",
"#CC9900", "#CC9933", "#CC9966", "#CC9999", "#CC99CC", "#CC99FF", "#FF9900", "#FF9933", "#FF9966", "#FF9999", "#FF99CC",
"#FF99FF", "#00CC00", "#00CC33", "#00CC66", "#00CC99", "#00CCCC", "#00CCFF", "#33CC00", "#33CC33", "#33CC66", "#33CC99",
"#33CCCC", "#33CCFF", "#66CC00", "#66CC33", "#66CC66", "#66CC99", "#66CCCC", "#66CCFF", "#99CC00", "#99CC33", "#99CC66",
"#99CC99", "#99CCCC", "#99CCFF", "#CCCC00", "#CCCC33", "#CCCC66", "#CCCC99", "#CCCCCC", "#CCCCFF", "#FFCC00", "#FFCC33",
"#FFCC66", "#FFCC99", "#FFCCCC", "#FFCCFF", "#00FF00", "#00FF33", "#00FF66", "#00FF99", "#00FFCC", "#00FFFF", "#33FF00",
"#33FF33", "#33FF66", "#33FF99", "#33FFCC", "#33FFFF", "#66FF00", "#66FF33", "#66FF66", "#66FF99", "#66FFCC", "#66FFFF",
"#99FF00", "#99FF33", "#99FF66", "#99FF99", "#99FFCC", "#99FFFF", "#CCFF00", "#CCFF33", "#CCFF66", "#CCFF99", "#CCFFCC",
"#CCFFFF", "#FFFF00", "#FFFF33", "#FFFF66", "#FFFF99", "#FFFFCC", "#FFFFFF"); var total = colors.length;var width = 18;var Cp_contents = ""; var windowref = (windowmode)? Window.opener. ":" "; if (windowmode) {cp_contents ="

Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta content= "text/html; Charset=utf-8 "http-equiv=" Content-type "/>
<title> colour selector color picker,internet explorer,firefox,opera,safar,ace explorer,avant browser,flock,google Chrome , Konqueror,netscape,seamonkey </title>
<meta name= "Author" content= "Geovin Du smear poly wen"/>
<meta name= "Keywords" content= "Geovin Du smear poly wen"/>
<meta name= "Description" content= "Geovin Du smear poly wen"/>
<script type= "Text/javascript" language= "JavaScript" src= "Colorpicker2.js" ></script>
<script type= "Text/javascript" language= "JavaScript" >
var cp = new ColorPicker (' window '); Popup window
var cp2 = new ColorPicker (); DIV style
</script>
<body>
<form>
<table border= "1" >
<tr>
<td>
This popup uses a "window" popup. Use this<br/>
For browsers that don ' t support dhtml.<br/>
Color: <input type= "text" name= "color" size= "value=" "/> <a href=" # "onclick=" Cp.select (document.forms[0). Color, ' pick '); return false; "Name=" Pick "id=" pick ">Pick</a>
</td>
</tr>
</table>
<br/>
<table border= "1" >
<tr>
<td>
This popup uses a DHTML "layer". It looks<br/>
Nicer, but won ' t work in older browsers
The color popup won ' t display over some form<br/>
Elements in some browsers!<br/>
Color: <input type= "text" name= "Color2" size= "value=" "/> <a href=" # "onclick=" Cp2.select (document.forms[0 ].color2, ' Pick2 '); return false; "Name= Pick2" id= "Pick2" >Pick</a>
</td>
</tr>
</table>
</form>
<script type= "Text/javascript" language= "JavaScript" >cp.writediv () </script>
</body>

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.