首页 > Web开发 > 详细

js禁止

时间:2017-10-29 13:21:45      阅读:222      评论:0      收藏:0      [点我收藏+]

很多时候需要用到js禁止相关的代码:

function prohibit() {
  // 禁止右键
  $(document).ready(function() {
    $(document).bind("contextmenu", function(e) {
      return false;
    }); 
  
    // 禁止a
    $("a").each(function() {
      $(this).css("cursor", "default"); // 修改鼠标样式
      $(this).removeAttr(‘href‘); //移除href 属性
      $(this).click(function(event) {
        event.preventDefault(); // 如果<a>定义了 target="_blank“ 需要这句来阻止打开新页面
      });

    });
  });
}
prohibit();

 

js禁止

原文:http://www.cnblogs.com/andyhxl/p/7749707.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!