日期:2014-05-16 浏览次数:20334 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="author" content="www.budingwang.com" /> <title>无标题 1</title> </head> <body> <a id="test" href="http://www.baidu.com">link to baidu</a> </body> <script> document.getElementById("test").addEventListener("click",stopLink,false); function stopLink(){ this.preventDefault(); //我想阻止它链接到百度,可发现这样写不行。 //怎样才能在绑定的函数中阻止默认行为? } </script> </html>