本文介绍了如何在IE,Netscape 4和Netscape 6中禁用右键菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 这解释了如何禁用 Netscape 4,Netscape 6和Internet Explorer(IE)中的视图源/右键菜单。 < ; script language =" JavaScript"> //此代码是右键单击禁用的开始 函数右(e){ //此功能适用于Net 4. if(navigator.appName ==''Netscape''&&(e.which == 3 || e.which == 2)) { 返回false; } 返回true; } 函数context(){ //这个函数负责Net 6和IE。 返回false; } document.onmousedown =权利; document.oncontextmenu = context; < / script> 注意:如果你设置了一个框架页面,并且在每个框架中都包含上面的 代码,临时用户将无法查看来源。如果你使用 帧,浏览器菜单选项查看源代码只会查看主要的 帧页面源,而不是单个帧源。但是,任何 复杂的用户仍然可以通过关闭javascript或者使用无法识别的浏览器来查看所有来源。 > 这个脚本。 注意:只有在Windows XP机器上测试过,运行风险自负。你可能需要调整其他平台/浏览器的代码,但你可以从这个样本中得到这个想法。 我发布这个的原因是新手 很难在网上找到这些信息,因为有大量的帖子 声明这个不可能,以及同样数量巨大的帖子 严厉谴责这是你可以对网页做的最糟糕的事情。 这篇帖子适合那些只想要的人满足客户的需求。即使请求是一个坏主意,客户仍然支付 账单:) 解决方案 是的,但如果你做得好,客户会更好地评判你,不是他们在第一名要求的未受过教育的b $ b。无论哪种方式,他们仍然支付账单,但如果他们得到一份好工作 - 他们建议你 其他人。 吉姆。 - comp.lang.javascript常见问题 - http://jibbering.com/faq/ 你整晚收费多少? yaktipper写道: 我以为是新手?新手不应该有顾客,他们应该学习。 - David Dorward http://david.us-lot.org/ 重新设计正在进行中: http://stone.thecoreworlds.net/ 微软宣布IE死了(所以升级): http://minutillo.com/steve/weblog/20...ces-ie-is-dead This explains how to disable the view source / right-click menu inNetscape 4, Netscape 6 and Internet Explorer (IE).<script language="JavaScript">//This code is the beginning of the right click disablefunction right(e) {//This function is for Net 4.if (navigator.appName == ''Netscape'' && (e.which == 3 || e.which ==2)){return false;}return true;}function context(){//This function takes care of Net 6 and IE.return false;}document.onmousedown=right;document.oncontextmenu=context;</script>Note: If you set up a frame page, and in each frame include the abovecode, the casual user will not be able to view the source. If you useframes, the browser menu option "View Source" will only view the mainframe page source, not the individual frame source. However, anysophisticated user will be able to still view all the source simply byturning off javascript, or by using a browser that doesn''t recognizethis script.Note: Only tested on a Windows XP machine, run at your own risk. Youmay need to tweak the code for other platforms/browers, but you canget the idea from this sample.The reason I''m posting this is that it is very difficult for a noviceto find this information on the Net, as an immense amount of postsdeclare this as impossible, and an equally immense amount of postsscathingly denounce this as the worst thing you can do to a web page.This post is for those people that simply want to meet a customer''sneeds. Even if the request is a bad idea, customers still pay thebills :) 解决方案Yes, but customers judge you better if you do a good job, not theuneducated bodge they asked for in the 1st place. Either way theystill pay the bill, but if they get a good job - they recommend you toothers.Jim.--comp.lang.javascript FAQ - http://jibbering.com/faq/How much do you charge for all night?I thought it was for novices? Novices shouldn''t have customers, they shouldbe learning.--David Dorward http://david.us-lot.org/Redesign in progress: http://stone.thecoreworlds.net/Microsoft announces IE is dead (so upgrade): http://minutillo.com/steve/weblog/20...ces-ie-is-dead 这篇关于如何在IE,Netscape 4和Netscape 6中禁用右键菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!