内嵌事件处理函数的解决办法 用户在点击某个链接时弹出一个新的窗口。

 
 

用户在点击某个链接时弹出一个新的窗口。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <ul id="ulList">
        <li>
            <a href="4_5_2_continue语句.html">4_5_2_continue语句.html</a>
        </li>
        <li>
            <a href="4_6_1_throw语句.html">4_6_1_throw语句.html</a>
        </li>
    </ul>
    <script type="text/javascript">
        //window.open(url,name,features)
        function popUp(winURL){
            window.open(winURL,"popup","width=320,height=480");
        }
        window.onload=function(){
            if(!document.getElementById) return false;
            if(!document.getElementsByTagName) return false;
            var ulList=document.getElementById("ulList");
            var links=ulList.getElementsByTagName("a");
            if(links.length>0){
                for(var i=0;i<links.length;i++){
                    links[i].onclick=function(){
                        popUp(this.getAttribute("href"));
                        return false;
                    }
                }
            }
        }
    </script>
</body>
</html>


你可能感兴趣的:(JavaScript,dom)