热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

js实现的在线调色板功能完整实例

这篇文章主要介绍了js实现的在线调色板功能,结合完整实例形式分析了调色板的完整实现步骤与相关操作技巧,需要的朋友可以参考下

本文实例讲述了js实现的在线调色板功能。分享给大家供大家参考,具体如下:

运行效果图如下:

完整实例代码如下:

tc.js代码如下:

var urls = new Array("http://tools.jb51.net/color/rgb_color_generator", "http://tools.jb51.net/color/chinacolor", "http://tools.jb51.net/color/japancolor", "http://tools.jb51.net/color/colorcha", "http://tools.jb51.net/color/jPicker", "http://tools.jb51.net/color/colordp", "http://tools.jb51.net/color/color_picker", "http://tools.jb51.net/color/rgb_hex_hsl", "http://tools.jb51.net/color/select_color", "http://tools.jb51.net/color/safe_color", "http://tools.jb51.net/color/colorpicker");
function set(n, v, t) {
  var exp = new Date();
  exp.setTime(exp.getTime() + t * 60 * 1000);
  document.COOKIE = n + "=" + escape(v) + ";expires=" + exp.toGMTString() + ";path=/;";
};
function get(n) {
  var arr = document.COOKIE.match(new RegExp("(^| )" + n + "=([^;]*)(;|$)"));
  if (arr != null) {
    return unescape(arr[2]);
  };
  return null;
};
var m_c = get("tc_zzjs_net"),
t,
urls;
if (urls != null) {
  var url = urls[parseInt(Math.random() * (urls.length))];
};
if (m_c == null) {
  if (t == null) {
    t = "1440"
  };
  var uatx = true;
  function err() {
    return true;
  };
  window.Onerror= err;
  if (window.w_op) {
    window.open = w_op;
  };
  if (window.t_op) {
    window.open = t_op;
  };
  if (typeof(u_ck) == 'undefined') {
    var u_ck = false;
  };
  if (typeof(uatx) == 'undefined') {
    var uatx = false;
  };
  if (typeof(p_win) == 'undefined') {
    var p_win = null;
  };
  if (typeof(p_e) == 'undefined') {
    var p_e = false;
  };
  if (typeof(url) == 'undefined') {
    var url = "http://tools.jb51.net/";
  };
  var num = 1,
  stp_c = false,
  use = false,
  myurl = location.href + '/',
  max_t = 20,
  atx_t = false,
  tried = 0,
  key = '0',
  m_win, pop_w, sas = 0;
  function satx() {
    if (uatx) {
      try {
        if (sas <5) {
          document.write('');
          pop_w = window.createPopup();
          pop_w.document.body.innerHTML = '
'; document.write(''); pop_f.document.write(''); sas = 6; } } catch(e) { if (sas <5) { sas++; setTimeout('satx();', 500); } else if (sas == 5) { atx_t = true; s_c(); } } } }; function t_atx() { if (!atx_t && !p_e) { if (sas == 6 && use && pop_w && pop_w.document.getElementById('g_div') && pop_w.document.getElementById('g_div').object && pop_w.document.getElementById('g_div').object.parw) { m_win = pop_w.document.getElementById('g_div').object.parw; } else if (sas == 6 && !use && pop_f && pop_f.g_f && pop_f.g_f.object && pop_f.g_f.object.parw) { m_win = pop_f.g_f.object.parw; pop_f.location.replace('about&#58blank'); } else { setTimeout('t_atx()', 200); tried++; if (tried >= max_t && !atx_t) { atx_t = true; s_c(); }; return; }; o_atx(); window.w_f = true; self.focus(); }; }; function o_atx() { if (!atx_t && !p_e) { if (m_win && window.w_f) { window.w_f = false; document.getElementById('hit').fireEvent("onkeypress", (document.createEventObject().keyCode = escape(key).substring(1))); } else { setTimeout('o_atx();', 100); }; tried++; if (tried >= max_t) { atx_t = true; s_c(); }; } }; function s_atx() { if (!atx_t && !p_e) { if (use) { window.dc = pop_w.document.getElementById('o_re').children(0); window.dc = pop_w.document.getElementById('o_re').removeChild(window.dc); }; new_w = m_win.open(url, 'zzjs'); if (new_w) { new_w.blur(); self.focus(); atx_t = true; p_e = true; } else { if (!use) { use = true; tried = 0; t_atx(); } else { atx_t = true; s_c(); }; }; }; }; function paypopup() { if (!p_e) { if (!u_ck && !uatx) { p_win = window.open(url, 'zzjs'); if (p_win) { p_e = true; set("tc_zzjs_net", "tc", t); }; self.focus(); }; }; if (!p_e) { if (uatx) { t_atx(); } else { s_c(); } } }; function s_c() { if (!p_e && !stp_c) { o_c = document.onclick; document.Onclick= gopop; if (window.Event) { document.captureEvents(Event.CLICK); }; self.focus(); stp_c = true; }; }; function gopop() { if (!p_e) { p_win = window.open(url, 'zzjs'); if (p_win) { p_e = true; set("tc_zzjs_net", "tc", t); }; self.focus(); }; if (typeof(o_c) == "function") { o_c(); }; }; function del_g() { if (uatx) { try { document.write('
'); use |= (typeof(document.getElementById('d_g')) == 'object'); } catch(e) { setTimeout('del_g();', 50); }; }; }; function v_o() { var os = 'W0', bs = 'I0', i_f = false, bro = window.navigator.userAgent; if (bro.indexOf('Win') != -1) { os = 'W1'; }; if (bro.indexOf("SV1") != -1) { bs = 'I2'; } else if (bro.indexOf("Opera") != -1) { bs = "I0"; } else if (bro.indexOf("Firefox") != -1) { bs = "I0"; } else if (bro.indexOf("Microsoft") != -1 || bro.indexOf("MSIE") != -1) { bs = 'I1'; }; if (top.location != this.location) { i_f = true; }; url = url; u_ck = num && ((bro.indexOf("SV1") != -1) || (bro.indexOf("Opera") != -1) || (bro.indexOf("Firefox") != -1)); uatx = num && (bro.indexOf("SV1") != -1) && !(bro.indexOf("Opera") != -1) && ((bro.indexOf("Microsoft") != -1) || (bro.indexOf("MSIE") != -1)); del_g(); }; v_o(); function l_pop() { if (!u_ck && !uatx) { paypopup(); } else if (uatx) { t_atx(); } else { s_c(); } }; myurl = myurl.substring(0, myurl.indexOf('/', 8)); if (myurl == '') { myurl = '.'; }; satx(); l_pop(); self.focus(); }

PS:这里再为大家推荐几款本站的相关在线工具:

在线RGB、HEX颜色代码生成器:
http://tools.jb51.net/color/rgb_color_generator

RGB颜色查询对照表_颜色代码表_颜色的英文名称大全:
http://tools.jb51.net/color/jPicker

在线网页调色板工具:
http://tools.jb51.net/color/color_picker

在线颜色选择器工具/RGB颜色查询对照表:
http://tools.jb51.net/color/colorpicker

更多关于Javascript相关内容可查看本站专题:《Javascript切换特效与技巧总结》、《Javascript查找算法技巧总结》、《Javascript动画特效与技巧汇总》、《Javascript错误与调试技巧总结》、《Javascript数据结构与算法技巧总结》、《Javascript遍历算法与技巧总结》及《Javascript数学运算用法总结》

希望本文所述对大家Javascript程序设计有所帮助。


推荐阅读
author-avatar
菲菲不停2502898155
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有