JS代码隐藏网页上点中的元素
// Click on an element (image, etc.) to hide, press Escape when finished. // My site: andrew.dx.am javascript:(function(){var d=document,useMine=true,prevEl;function AddHandler(orig,mine) {return function(e){if(useMine)mine(e);else if(orig)orig(e);};}function Myonmouseover(e) {var evt=e||window.event;var elem=evt.target||evt.srcElement;elem.style.outline='2px solid gray'; prevEl=elem;}function Myonmouseout(e){var evt=e||window.event;var elem=evt.target||evt.srcElement;elem.style.outline='';} function Myonclick(e){var evt=e||window.event;var elem=evt.target||evt.srcElement;elem.style.display='none';} function Myonkeydown(e){var evt=e||window.event;if(evt.keyCode==27){prevEl.style.outline='';useMine=false;}} d.onmouseover=AddHandler(d.onmouseover,Myonmouseover);d.onmouseout=AddHandler(d.onmouseout,Myonmouseout); d.onclick=AddHandler(d.onclick,Myonclick);d.onkeydown=AddHandler(d.onkeydown,Myonkeydown);})() // Here's the expanded code as well: javascript: (function(){ var d=document,useMine=true,prevEl; function AddHandler(orig,mine){ return function(e){ if(useMine) mine(e); else if(orig)orig(e); }; } function Myonmouseover(e){ var evt=e||window.event; var elem=evt.target||evt.srcElement; elem.style.outline='2px solid gray'; prevEl=elem; } function Myonmouseout(e){ var evt=e||window.event; var elem=evt.target||evt.srcElement; elem.style.outline=''; } function Myonclick(e){ var evt=e||window.event; var elem=evt.target||evt.srcElement; elem.style.display='none'; } function Myonkeydown(e){ var evt=e||window.event; if(evt.keyCode==27){ prevEl.style.outline=''; useMine=false; } } d.onmouseover=AddHandler(d.onmouseover,Myonmouseover); d.onmouseout=AddHandler(d.onmouseout,Myonmouseout); d.onclick=AddHandler(d.onclick,Myonclick); d.onkeydown=AddHandler(d.onkeydown,Myonkeydown); } )()