/*
document.oncontextmenu=new Function("event.returnValue=false;");
document.oncontextmenu=new Function("event.returnValue=false;");
document.onselectstart=new Function("event.returnValue=false;");
*/
以上代码对于iframe页面失效,以下作了改进*/
var iframe = document.getElementById('ifm');
iframe.onload=function(){
iframe.contentWindow.document.oncontextmenu=function(){return false;};
iframe.contentWindow.document.onselectstart=function(){return false;};
};
这样就可以屏蔽网页右键了.是不是很简单!!!
转载请注明:前端录»iframe页面屏蔽网页右键代码