FireFox与IE 下js兼容
触发
click 事件 ,对于需要兼容这两者的朋友,就需要参考下下面的代码了
<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>