解决了火狐下无法触发click事件的问题
<script language="javascript"> 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> <a href="#" id="a3" onclick="location.href = ‘http://www.baidu.com‘;">baidu</a> <input type="button" value="clck" onclick="test2(‘a3‘);"/>
时间: 2024-09-29 04:16:45