< a href =" javascript"> ?? [英] <a href="javascript"> ??

查看:107
本文介绍了< a href =" javascript"> ??的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在写作:

< span onclick =" window.open(...);" > Klick Here< / span>


但我想使用< a href>为此,因为它是在我希望我的链接打开的方式在

css脚本中定义的。现在,如果我使用href,

href也将被执行。如果启用了javascript,我可以用什么才能使href

不执行?

-

-Gernot

int main(int argc,char ** argv){printf

("%silto%c%cf%cgl%ssic%ccom%c"," ma",58, ''g'',64," ba",46,10);}


________________________________________

寻找好游戏?亲自动手吧!

GLBasic - 你可以这样做
www.GLBasic .com

推荐答案

Gernot Frisch于2006年6月26日在comp.lang.javascript中写道
Gernot Frisch wrote on 26 jun 2006 in comp.lang.javascript:


我正在写作:
< span onclick =" window.open(...);"> ; Klick Here< / span>

但我想使用< a href>为此,因为它是在我希望我的链接打开的方式在
css脚本中定义的。现在,如果我使用href,
href也将被执行。如果启用了javascript,我可以使用什么才能使href
不执行?
Hi,

I''m currently writing:
<span onclick="window.open(...);">Klick Here</span>

but I want to use the <a href> for this, since it is defined in the
css script the way I want my link to open. Now, if I use a href, the
href will be executed as well. What can I du in order to make the href
not execute if javascript is enabled?




onclick =" window.open(...);返回false;


-

Evertjan。

荷兰。

(请在我的电子邮件地址中将x''es更改为点数)



onclick="window.open(...);return false;"

--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)


Gernot Frisch写道:
Gernot Frisch wrote:


我我正在写作:
< span onclick =" window.open(...);"> Klick Here< / span>

但我想用< a href>为此,因为它是在我希望我的链接打开的方式在
css脚本中定义的。现在,如果我使用href,
href也将被执行。如果启用了javascript,我可以使用什么才能使href
不执行?
Hi,

I''m currently writing:
<span onclick="window.open(...);">Klick Here</span>

but I want to use the <a href> for this, since it is defined in the
css script the way I want my link to open. Now, if I use a href, the
href will be executed as well. What can I du in order to make the href
not execute if javascript is enabled?




我认为通常接受的方法是使用以下内容: br />

< a href =" NoJSError.html"的onclick = QUOT; window.open(...);返回false;">

Klick Here

< / a>


在window.open之后(... )执行,返回false;将确保不会执行链接的默认操作。


如果没有可用的JS,将显示NoJSError.html,解释

需要启用JavaScript以使您的网站正常工作。


注意:

即使启用了JS, ifwindow.open(...);由于某种原因失败,

return false;将不会被执行,并且href将被跟踪。


-

Dag。







I think the commonly accepted way is to use the following:

<a href="NoJSError.html" onclick="window.open(...); return false;">
Klick Here
</a>

After window.open(...) is executed, return false; will make sure thet
the default action to follow the link is not executed.

If there is no JS available, the NoJSError.html will be shown, explaining
that JavaScript needs to be enabled for your site to work properly.

NOTE:
Even if JS is enabled, if "window.open(...);" fails for some reason,
the "return false;" will not be executed, and the href will be followed.

--
Dag.






Gernot Frisch写道:
Gernot Frisch wrote:
为了使href无法执行,我还能做什么? javascript已启用?
What can I du in order to make the href
not execute if javascript is enabled?



http:/ /www.javascripttoolbox.com/bestpractices/#onclick


-

Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com



http://www.javascripttoolbox.com/bestpractices/#onclick

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com


这篇关于&lt; a href =&quot; javascript&quot;&gt; ??的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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