请问以下程序为何运行不出来??
<html>
<head>
<title>outerhtml应用实例</title><script language="javascript">function initialize()
{
 objmytext=document.all["mytext"];
 document.all["fieldotext"].value=objmytext.outerHTML;
}
function update(objButton)
{
 buttonid=objButton.id;
 objnewtext=document.all["mytext"];
 if(buttonid=="buttonotext")
   objnewtext.outerHTML=document.all["fieldotext"].value;
initialize();
}   </script>
</head>
<body onLoad="initialize()"><p id="mytext">dhtml好处多</p>
innerHTML:
<input id=fieldotext type=text size=40>
<input type=button value="改变" onClick="update(this)"></body>
</html>

解决方案 »

  1.   


    <input id="buttonotext" type=button value="改变" onClick="update(this)"> 
      

  2.   

    <html> 
    <head> 
    <title>outerhtml应用实例 </title> <script language="javascript"> function initialize() 

     objmytext=document.all["mytext"]; 
     document.all["fieldotext"].value=objmytext.outerHTML; 

    function update(objButton) 

     buttonid=objButton.id; 
     objnewtext=document.all["mytext"]; 
     if(buttonid=="buttonotext") 
       objnewtext.outerHTML=document.all["fieldotext"].value; 
       alert(1);
    initialize(); 
    }    </script> 
    </head> 
    <body onLoad="initialize()"> <p id="mytext">dhtml好处多 </p> 
    innerHTML: 
    <input id=fieldotext type=text size=40> 
    <input id="buttonotext" type=button value="改变" onClick="update(this)"> </body> 
    </html>
    你的button少了id,判断那没有执行所以看不到改变,给button加id 就可以了。