禁止调试前端页面

https://cdn.jsdelivr.net/npm/[email protected]/dist/console-ban.min.js

name required type default description
clear no boolean true Disable console.clear
debug no boolean true Whether to enable infinity debugger
debugTime no number 3000 The debugger execution interval
redirect no string - Redirect url when console is opend
write no string | Element - Rewrite document.body content when console is opend
callback no Function - Custom callback when console is opend
bfcache no boolean true Disable bfcache

// 禁用鼠标右键  
document.oncontextmenu = function() {  
    return false;  
};

 

 // default options
 ConsoleBan.init() 
// custom options 
ConsoleBan.init({ redirect: '/404' })
ConsoleBan.init({
  // Redirect to /404 relative url
  redirect: '/404',
  // Redirect to absolute url
  redirect: 'http://domain.com/path'
})

var div = document.createElement('div')
div.innerHTML = 'Stop'

ConsoleBan.init({
  // Rewrite the  as a string
  write: '

Stop

', // or rewrite a element write: div })

ConsoleBan.init({
  callback: () => {
    // ...
  }
})

你可能感兴趣的:(前端)