onclick =" alert('hello'); return false;"在IE7中不起作用? [英] onclick="alert('hello');return false;" does not work in IE7?

查看:77
本文介绍了onclick =" alert('hello'); return false;"在IE7中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




通常,一段代码如


< a href =" http:// www。 yahoo.com" onclick =" alert(''hello''); return

false;"> link< / a>


将停止浏览器实际上是去href'的目的地。

但是,我使用的IE7并非如此。

改变了什么?


IE7版本:7.0.5730.11。更新版本:0


有没有人遇到过这个问题?我如何解决这个问题?

谢谢。

测试用例:

--------------- --------


< html>


< body>

< phello1< / p>

< a href =''http://www.yahoo.com''onclick =" alert(''clicked'');返回

false;">我的测试链接< / a>

< / body>

< / html>

推荐答案

al ****** @ gmail.com 写道:
al******@gmail.com wrote:




通常,一段代码如

< a href =" http://www.yahoo.com" onclick =" alert(''hello''); return

false;"> link< / a>


将停止浏览器实际上是去href'的目的地。

但是,我使用的IE7并非如此。

改变了什么?
Hi,

Normally, a piece of code such as

<a href="http://www.yahoo.com" onclick="alert(''hello'');return
false;">link</a>

will stop the browser from actually going to href''s destination.
However, this is not the case with the IE7 I am using. What has
changed?



''return'后你有换行符,所以javascript会插入一个分号
$ b'b''false''之前。尝试取出换行符并且工作正常。

You have a newline after ''return'', so javascript will insert a semicolon
before ''false''. Try taking out the newline and it works fine.



al ****** @ gmail.com 写道:




通常,一段代码如


< a href =" http://www.yahoo.com" onclick =" alert(''hello''); return

false;"> link< / a>


将停止浏览器实际上是去href'的目的地。

但是,我使用的IE7并非如此。

改变了什么?
Hi,

Normally, a piece of code such as

<a href="http://www.yahoo.com" onclick="alert(''hello'');return
false;">link</a>

will stop the browser from actually going to href''s destination.
However, this is not the case with the IE7 I am using. What has
changed?



[...]

[...]


Testcase :

-----------------------


< html>


< body>

< phello1< / p>

< a href =''http:// www .yahoo.com''onclick =" alert(''clicked'');返回

false;">我的测试链接< / a>

< ; / body>

< / html>
Testcase:
-----------------------

<html>

<body>
<phello1 </p>
<a href = ''http://www.yahoo.com'' onclick="alert(''clicked'');return
false;">my test link</a>
</body>
</html>



HTML无效,A元素必须位于块元素内。我是

amost肯定与它无关,特别是在IE关注的地方,但你永远都不知道! ;-)


-

Rob

The HTML is invalid, an A element must be inside a block element. I''m
amost certain that has nothing to do with it, particularly where IE is
concerned, but you never know! ;-)

--
Rob


RobG写道:
RobG wrote:
al******@gmail.com 写道:

>

通常,一段代码如

< a href =" http: //www.yahoo.com" onclick =" alert(''hello''); return
false;"> link< / a>

将阻止浏览器实际进入href'的目的地。
但是,我使用的IE7并非如此。
改变了什么?
>Hi,

Normally, a piece of code such as

<a href="http://www.yahoo.com" onclick="alert(''hello'');return
false;">link</a>

will stop the browser from actually going to href''s destination.
However, this is not the case with the IE7 I am using. What has
changed?



[...]

[...]


>测试用例:
-----------------------

< html>

< body>
< phello1< / p>
< a href ='''http://www.yahoo.com''onclick =" alert(''clicked''); return
false;">我的测试链接< / a>
< / body>
< / html>
>Testcase:
-----------------------

<html>

<body>
<phello1 </p>
<a href = ''http://www.yahoo.com'' onclick="alert(''clicked'');return
false;">my test link</a>
</body>
</html>



HTML无效,A元素必须位于块元素内。我是

amost肯定与它无关,特别是在IE关注的地方,但你永远都不知道! ;-)


The HTML is invalid, an A element must be inside a block element. I''m
amost certain that has nothing to do with it, particularly where IE is
concerned, but you never know! ;-)



仅适用于XHTML。由于没有doctype,IE将暗示

HTML4,iirc。我和Duncan Booth在这个帖子的其他地方:新线

就是问题。


-

Martijn Saly

That only goes for XHTML. And since there''s no doctype, IE will imply
HTML4, iirc. I''m with Duncan Booth elsewhere in this thread: the newline
is the problem.

--
Martijn Saly


这篇关于onclick =&quot; alert('hello'); return false;&quot;在IE7中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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