有个异步调用后点击链接的需求,实现如下:
htm代码
<a href="#ordertable" title="" id="cbox"></a>
js代码
var alabel = document.getElementById("cbox");
alabel.href = "xxx";
if (document.all) {
// For IE
alabel.click();
} else if (document.createEvent) {
//FOR DOM2
var ev = document.createEvent('HTMLEvents');
ev.initEvent('click', false, true);
alabel.dispatchEvent(ev);
}