JavaScript OnClick跨浏览器友好? [英] Javascript OnClick cross-browser friendly?
本文介绍了JavaScript OnClick跨浏览器友好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在所有浏览器中使用以下版本?
Can I use the following across all browsers?
<a href="#" onclick="doSomething()">Click here.</a>
这是关于标准的不良做法吗?
Is this "bad practice" in regards to standards?
它会在IE,FF,Safari和Chrome上使用吗?
Will it work on IE, FF, Safari and Chrome?
推荐答案
我在所有浏览器中使用以下版本?
Can I use the following across all browsers?
是
这是关于标准的不良做法吗?
Is this "bad practice" in regards to standards?
不良做法 。
- 这不是 unobtrusive 。
- 它链接到页面顶部(
#
),并且总是发送浏览器到那里,即使JS运行。 - 如果JS失败,则没有什么有用的。您应该基于工作的东西。
- It is not unobtrusive. Event handlers are better applied with JS.
- It links to the top of the page (
#
) and will always send the browser there, even if the JS runs. - If the JS fails, then nothing useful will happen. You should build on stuff that works.
它可以在IE,FF,Safari和Chrome上使用吗?
Will it work on IE, FF, Safari and Chrome?
是
这篇关于JavaScript OnClick跨浏览器友好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文