栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

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

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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程序设计有所帮助。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/91694.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号