<html>
<script type='text/javascript'>
function create_link()
{
function _alert() {
alert("hello");
}
var div=document.createElement('div');
div.innerHTML = "<a href=\"javascript:_alert()\">alink</a>"
document.getElementById('h').appendChild(div);
}
</script>
<body>
<h4 id='h'></h4>
<input type='button' value='create' onmouseup='create_link();' />
</body>
</html>现在需要用href调用嵌套函数,代码和上面类似发现不行。大伙有什么解决方法?谢谢

解决方案 »

  1.   


    <html> 
    <script   type='text/javascript'> 
    function   Hello() { 
    alert("hello"); 

    function   create_link() 
    { var   div=document.createElement('div'); 
    div.innerHTML   =   " <a   href=\"javascript:Hello()\"> alink </a> " 
    document.getElementById('h').appendChild(div); 
    }
    </script> 
    <body> 
    <h4   id='h'> </h4> 
    <input   type='button'   value='create'   onmouseup='create_link();'   /> 
    </body> 
    </html> 
      

  2.   

    你的
    function   _alert()   { 
    alert("hello"); 
    }
    是 function   create_link() 的私有函数,怎么可以访问得到!