我也遇到过类似的问题,你看看下面这俩连接
http://topic.csdn.net/u/20080407/23/a9d724d8-d9a0-4e5e-99b2-64257913f9c4.htmlhttp://topic.csdn.net/u/20071025/00/a7f08175-5fad-4867-9842-abe04110fef1.html
http://topic.csdn.net/u/20080407/23/a9d724d8-d9a0-4e5e-99b2-64257913f9c4.htmlhttp://topic.csdn.net/u/20071025/00/a7f08175-5fad-4867-9842-abe04110fef1.html
inn+="document.write(\"from button click \");";
inn+=" \<\/script\>";
inn="";
inn +=" <script type=\"text/javascript\">";
inn+="document.write(\"from button click \");";
inn+=" <\/script>1";
divaa.innerHTML=inn;
你稍微再后面一个一些数字或者字就知道了!实际上已经赋值了
我觉得你这个纯粹多余
直接inn="from button click ";不好?
<head>
<script type="text/javascript">
function aa()
{
inn="";
inn +=" <script type=\"text/javascript\">";
inn+="document.write(\"from button click \");";
inn+=" <\/script>";divaa.innerHTML=inn;
eval("document.write(\"from button click \");");}
</script>
</head><body>
<table>
<tr>
<td>
<input type="button" value="div script" onClick="aa()" />
</td>
</tr><tr>
<td>
<div id="divaa">
<script type="text/javascript">
document.write("from div ");
</script>
</div>
</td>
</tr>
</body>
</html>参考这个:xmlhttp.open("GET","A-1.html",false)
xmlhttp.send(null);
if(window.navigator.userAgent.indexOf("Firefox")>=1) //针对FF
{
document.getElementById("oDiv").innerHTML = xmlhttp.responseText;
var scripts = document.getElementById("oDiv").getElementsByTagName("script");
for(var i=0;i <scripts.length;i++) //一段一段执行script
{
eval(scripts[i].innerHTML);
}
}else if(window.navigator.userAgent.indexOf("MSIE")!=-1)
{
var httpText = xmlhttp.responseText;
httpText = httpText.replace(/ <script[^>]*>/gi," <script defer>")//因为 <script defer>可以在IE上直接运行,所以把所有的script标签都替换成defer标记的script
document.getElementById("oDiv").innerHTML = httpText;
}
</script></body>
</html>