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

简介

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

代码

<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://juejin.im/post/5d00f2f9518825019319ae29

猜你喜欢

转载自blog.csdn.net/weixin_33966095/article/details/93176045
今日推荐