在Firefox如何实现链接的click() ?想要通过脚本点击一个链接。是像这样的情况:<a href="http://www.abc.com" id="abc">abc</a>document.getElementById("abc").click()在IE和opera中正常,在firefox不行.不要用document.location.href=url的方法来实现,还有其它方法吗?
解决方案 »
- 怎样判断一个浏览器是360浏览器
- 为什么 我点击用flash做的按钮的时候 地址显示http:/// 不是完整的地址
- 求教
- |zyciis| 在Form的onsubmit事件中如何得到当前提交控件的ID 谢谢
- 两个javascript的基础问题·······················?
- 一个Javascript比较有挑战性的问题
- 求一小段代码,请大家帮帮忙?谢谢.................求一小段代码,请大家帮帮忙?谢谢
- 用showModalDialog()方法打开的窗口如何隐藏掉标题栏?
- 如何在javascript里取得文字码。
- 问一些基本问题,好心人来回答一下吧
- 紧急求助。javascript实现插入falsh问题
- 请问: 点击IE工具栏的返回按钮,让上一页自动刷新,代码是怎样的?
你还是换方法吧。。按钮可以。。<input id="abc" type="button" onclick="alert('wc')" />
<script type="text/javascript">
var $ = function (id) {
return document.getElementById(id);
};a = $("abc");
if (!document.createEvent) {
a.click();
} else {
var o = a.ownerDocument.createEvent("MouseEvents");
o.initEvent("click", false, true);
a.dispatchEvent(o);
}
</script>
---------------------------------------------------------------------
Gecko DOM Reference Summary The click method simulates a click on an element. Syntax element.click() Notes The click method is intended to be used with INPUT elements of type button, checkbox, radio, reset or submit. Gecko does not implement the click method on other elements that might be expected to respond to mouse–clicks such as links (A elements), nor will it necessarily fire the click event of other elements. Non–Gecko DOMs may behave differently. When a click is used with elements that support it (e.g. one of the INPUT types listed above), it also fires the element's click event which will bubble up to elements higher up the document tree (or event chain) and fire their click events too. However, bubbling of a click event will not cause an A element to initiate navigation as if a real mouse-click had been received. Specification click
---------------------------------------------------------------------------