页面中同时存在VBScript和Javascript时请注意

当一个页面里面同事存在Javascript和VBScript的时候,我们的页面可能会发生错误,错位位置在

<body
oncontextmenu="return false;"
onkeydown="parPage.KeyControl(event)"
onhelp="parPage.goHelp(event)"
bottomMargin="2"
leftMargin="2" topMargin="2" rightMargin="2">

此时,当触发了oncontextmenu事件后,浏览器不知道这个return false语句到底用什么引擎来解析,所以就会出现找不到对象或者类似的莫明其妙的错误.解决办法是在事件处理前,加上语言名称前缀:javascript:return false;

<body
 oncontextmenu="javascript:return false;"
onkeydown="javascript:parPage.KeyControl(event)"
onhelp="javascript:parPage.goHelp(event)"
bottomMargin="2" leftMargin="2" topMargin="2" rightMargin="2">

这样就不会出来那种无聊的错误了.

有人说写上这句就默认为javascript了,好像这句话不起作用

<meta name="vs_defaultClientScript" content="JavaScript">
Share
This entry was posted in 编程. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">