<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> #tet{ width: 200px; height: 300px; border: 1px solid; background: #00A7F6; display: none; } </style> </head> <body> <div id="head"> <input type="button" value="按钮"> <div id="tet"></div> </div> <script> var put=document.getElementsByTagName("input")[0]; var te=document.getElementById("tet"); // 解决火狐不能兼容某些事件的方法 // 设个参数最好是ev; put.onclick=function (ev) { // 当点击window事件执行时,先阻止其冒泡事件发生,如果遇到兼容性,不能执行,那就执行ev,消除兼容性 var eve=window.event||ev; te.style.display="block"; eve.cancelBubble=true; } document.onclick=function () { te.style.display="none" } </script> </body> </html>
解决火狐不能兼容某些事件的方法
猜你喜欢
转载自blog.csdn.net/xinye666666/article/details/80839386
今日推荐
周排行