FireFox与IE 下js兼容触发click事件的代码
时间:2022-07-24 10:15:28|栏目:JavaScript代码|点击: 次
<a href="#" id="a3" onclick="test()" style="display:none"></a>
<input type="button" value="clck" onclick="test2('a3');"/>
<script language="javascript">
function test()
{
document.location.href = "DBAI_les20_globalization_support.ppt";
}
function test2(name)
{
if(document.all)
{
document.getElementById(name).click();
}
else
{
var evt = document.createEvent("MouseEvents");
evt.initEvent("click", true, true);
document.getElementById(name).dispatchEvent(evt);
}
}
</script>
<input type="button" value="clck" onclick="test2('a3');"/>
<script language="javascript">
function test()
{
document.location.href = "DBAI_les20_globalization_support.ppt";
}
function test2(name)
{
if(document.all)
{
document.getElementById(name).click();
}
else
{
var evt = document.createEvent("MouseEvents");
evt.initEvent("click", true, true);
document.getElementById(name).dispatchEvent(evt);
}
}
</script>
栏 目:JavaScript代码
下一篇:Json格式详解
本文标题:FireFox与IE 下js兼容触发click事件的代码
本文地址:http://www.codeinn.net/misctech/208707.html