标签:color width window lan col 点击 nbsp oct eve
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <!-- oncontextmenu="return false", 兼容safari --> <div style="width: 200px; height: 200px; background: gray;" id="oDiv" oncontextmenu="return false"></div> <script> let oDiv = document.getElementById(‘oDiv‘); oDiv.oncontextmenu = ‘return false‘; oDiv.addEventListener(‘contextmenu‘, (e) => { if (e.preventDefault) { // W3c e.preventDefault(); } else { // IE window.event.returnValue = false; } return false; }) </script> </body> </html>
标签:color width window lan col 点击 nbsp oct eve
原文地址:https://www.cnblogs.com/bagexiaowenti/p/10115268.html