<html>
<head>
<title>this is a test js</title>
<script type="text/javascript">
function start(){
//alert(document.getElementById('aaa').href);
abc();
def();
}
function abc(){
document.getElementById('aaa').href="abc";
//alert('abc');
if (document.all) {
// For IE
document.getElementById('aaa').click();
} else if (document.createEvent) {
//FOR DOM2
var ev = document.createEvent('MouseEvents');
ev.initEvent('click', false, true);
document.getElementById('aaa').dispatchEvent(ev);
}
}
function def(){
document.getElementById('aaa').href = "def";
//alert('def');
if (document.all) {
// For IE
document.getElementById('aaa').click();
} else if (document.createEvent) {
//FOR DOM2
var ev = document.createEvent('MouseEvents');
ev.initEvent('click', false, true);
document.getElementById('aaa').dispatchEvent(ev);
}
}
</script>
</head>
<body οnlοad="start();">
<a id="aaa" href="http://aaa">评论</a>
</body>
</html>
自动执行js方法改变超链接的值,并实现自动点击
最新推荐文章于 2024-06-09 19:30:00 发布