日期:2014-05-16 浏览次数:20428 次
<script language="javascript" type="text/javascript"> //window.onerror=function(){return false;};//为false时 </script> <script language="javascript" type="text/javascript"> window.debugflag = true; function keydown(){ try{ if(arguments[0]&&(arguments[0].ctrlKey)&&(arguments[0].keyCode=='78')){ arguments[0].returnValue=false; var d =arguments[0]; alert('Reject this action! \n\nDocTitle:'+arguments[0].srcElement.document.title); } }catch(e){ if(window.debugflag)alert(e.message); } } document.onreadystatechange = function(){ if(document.readyState=="complete"){ addKeyDownListener(window.document); } } function frameonready(){ try { if(arguments[0]&&arguments[0].srcElement&&arguments[0].srcElement.readyState=="complete"){ var d = arguments[0].srcElement; d.contentWindow.document.attachEvent("onkeydown",keydown); } } catch (e) { if (window.debugflag)alert(e.message); } } function frameonload(){ try { alert("onload---\n\nDocTitle:"+arguments[0].srcElement.document.title); if(arguments[0].srcElement.readyState=="complete"){ var d = arguments[0].srcElement; d.document.attachEvent("onkeydown",keydown); if(d.contentWindow!=d.contentWindow.parent){ addKeyDownListener(arguments[0].srcElement.document); } } } catch (e) { if (window.debugflag)alert(e.message); } } function propertychange(e) { try { if(e.propertyName=='src'){ alert("src change"); arguments[0].srcElement.attachEvent("onreadystatechange",frameonready); addKeyDownListener(arguments[0].srcElement.document); } } catch (e) { if (window.debugflag) alert(e.message); } } function addKeyDownListener(doc) { try{ var len = 0; if (doc.frames) { len = doc.frames.length; } if (len > 0) { for ( var i = 0; i < len; i++) { //alert("frameName:"+doc.frames[i].name+"-- len:"+doc.frames[i].frames.length); if(!doc.frames[i].document.keydownEventCount){ doc.frames[i].document.attachEvent("onkeydown", keydown); doc.frames[i].document.keydownEventCount=1; } var tmpframe = doc.getElementsByTagName("FRAME")[i]; if(!tmpframe){//如果内嵌的是iframe tmpframe对象就为null tmpframe = doc.getElementsByTagName("IFRAME")[i]; if(!tmpframe.readyEventCount){//判断tmpframe对象是否已定义readyEventCount属性并赋值,若已定义并赋值了,说明就不需要再添加listener tmpframe.attachEvent("onreadystatechange",frameonready); tmpframe.readyEventCount=1; } }else if(!tmpframe.loadEventCount){ tmpframe.attachEvent("onload",frameonload); tmpframe.loadEventCount=1; } addKeyDownListener(doc.frames[i].document); } } } catch (e) { if (window.debugflag) alert(e.message); } } if (document.attachEvent) { document.attachEvent("onkeydown", keydown); } else { document.addEventListener("onkeydown", keydown, true); alert("Warning"); } </script>