JavaScript在Firefox下工作,但在IE下无法使用 [英] JavaScript works under Firefox but does not work under IE

查看:79
本文介绍了JavaScript在Firefox下工作,但在IE下无法使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



它可以很好地适用于Firefox,但是,当它用IE打开时,JavaScript似乎不会被调用。点击超链接后直接显示grading.pdf。

 < HTML> 
< HEAD>
< TITLE> JavaScript范例8< / TITLE>

< SCRIPT language =JavaScript>
<!--------

var password;

var pass1 =test;

password = prompt('请输入您的密码以查看此页!','');

if(password == pass1)
alert('Password Correct!Click OK to enter!');
else
{
window.location =jpass.htm;
}

// ----------->
< / SCRIPT>

< / HEAD>

< BODY bgcolor =#FFFFFFtext =#000000>

<! - < H1 align =center>< a href =grades.pdf>评分< / a>< / H1> - >

< CENTER>
<! - < A HREF =grades.htm>评分< / A> - >
< a href =grades.pdf>评分< / a>


解决方案

这是一种不安全的方法,可以通过用户在IE的高级属性中设置的安全确认来忽略或调用该方法。 (IE在window.prompt中使用了activeX)



安全更新也可能会将此行为应用于IE7。



获取至少在IE中,来自输入字段的输入而不是提示。

I am having the following HTML file protected through JavaScript.

It works fine with Firefox, howover, when it is opened with IE, the JavaScript seems not get invoked. The grading.pdf is directly displayed after clicking the hyperlink.

<HTML>
<HEAD>
<TITLE>JavaScript Example 8</TITLE>

<SCRIPT language="JavaScript">
<!--------

var password;

 var pass1="test";

 password=prompt('Please enter your password to view this page!',' ');

 if (password==pass1)
     alert('Password Correct! Click OK to enter!');
 else
    {
    window.location="jpass.htm";
     }

 //----------->
</SCRIPT>

</HEAD>

 <BODY bgcolor="#FFFFFF" text="#000000">

 <!--<H1 align="center"><a href="grades.pdf">grading</a></H1>-->

 <CENTER>
 <!--<A HREF="grades.htm">Grading</A>-->
<a href="grades.pdf">grading</a>

解决方案

IE 8 and above makes prompt an unsafe method, which may be ignored or called with a security confirmation, as set in advanced properties of IE by the user. (IE uses activeX in window.prompt)

Security updates may also apply this behavior to IE7.

Get the input from an input field instead of a prompt, at least in IE.

这篇关于JavaScript在Firefox下工作,但在IE下无法使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆