您现在的位置是:首页 > 文章详情

一段实现网站倒转特效的javascript代码

日期:2019-06-11点击:504

简介

之前 一直有人恼火我的网站双击会变成黑白,然后文字颠倒,其实实现这个很简单,把下面这段代码放到你的网站首页即可

代码

<script>
(function () {
  var __timeout;
  var __lastTap = 0;
  var hell = function hell() {
    var hell = document.getElementById('hell');
    if (hell) {
      hell.parentNode.removeChild(hell);
    } else {
      var style = document.createElement('style');
      style.id = 'hell';
      style.textContent = 'body{ background:black; -webkit-transform: scale(-1,1); -ms-transform: scale(-1,1); transform: scale(-1,1); -webkit-filter: sepia(0) saturate(0) invert(1) brightness(1) c
ontrast(1); filter: sepia(0) saturate(0) invert(1) brightness(1) contrast(1); }';
      document.head.appendChild(style);
    }
  };
  document.addEventListener('dblclick', hell, false);
  document.addEventListener('touchend', function () {
    var currentTime = new Date().getTime();
    var tapLength = currentTime - __lastTap;
    clearTimeout(__timeout);
    if (tapLength < 500 && tapLength > 0) {
      hell();
    }
    __lastTap = currentTime;
  });
})();
</script>

欢迎关注Bboysoul的博客www.bboysoul.com

Have Fun

原文链接:https://yq.aliyun.com/articles/705229
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章