该脚本与我的响应式模板的布局对齐冲突。我如何修复它?

时间:2017-05-05 07:41:35

标签: javascript css blogspot

我复制并自定义了一个从过去的stackoverflow讨论中获取的脚本。现在我可以阻止"打印屏幕"使用当前的组合键:" ctrl + alt + printscr" ," ctrl + printscr"和" alt + printscr"。但是在我保存了我的博客模板之后,我做了一些非常有效的测试:脚本真的很棒..但不像预期的那样,我遇到了两个问题:

  1. 如果我点击地址栏或让页面保持不活动状态,脚本会自动显示背景图片以覆盖布局。
  2. 如果我尝试调整窗口大小,则元素对齐失败..
  3. 我不熟悉javascript语言,所以我可能犯了一些错误。我拍了一张照片,向你展示问题的本质。

    PS:我的布局完全响应,我从来没有遇到过元素自动对齐的问题。然后我尝试删除最新的JavaScript,并再次完美。可能我在代码中犯了一些未知错误。

    I installed many anti-stealing protection scripts, jquery and css (but they not conflict apparently..) Here is a screen demostration of the problem

    以下是代码:

    <script language='JavaScript'>
    function copyToClipboard() {
      // Create a &quot;hidden&quot; input
      var aux = document.createElement(&quot;input&quot;);
      // Assign it the value of the specified element
      aux.setAttribute(&quot;value&quot;, &quot;You can no longer give printscreen. This is part of the new system security measure.&quot;);
      // Append it to the body
      document.body.appendChild(aux);
      // Highlight its content
      aux.select();
      // Copy the highlighted text
      document.execCommand(&quot;copy&quot;);
      // Remove it from the body
      document.body.removeChild(aux);
      alert(&quot;Print screen disabled.&quot;);
    }
    
    $(window).keyup(function(e){
      if(e.keyCode == 44){
        copyToClipboard();
      }
    }); 
    
    $(window).focus(function() {
      $(&quot;body&quot;).show();
    }).blur(function() {
      $(&quot;body&quot;).hide();
    });
    </script>
    

0 个答案:

没有答案