不要用document.write 用object.innerHTML

解决方案 »

  1.   

    利用server.htmlEncode(strDisp)可以实现你说的要求
    如下:
        var str = server.htmlEncode("<p><ahref='http://sohu.net'>sohu</a></p>");
        document.write(str);
    这样字符串中包含的html代码将会原样输出,而不会再被浏览器解释执行。
      

  2.   

    你们理解的错了
    第一:我现在必须用document.write
    第二:我不是不要它执行代码,我是让它执行,但是不知道怎么把源代码给字符串a
    然后document.write(a);
      

  3.   

    what kind of html are you trying to write?
      

  4.   

    document.write("/");
    这样不行吗?
      

  5.   

    <a href='http://sohu.net'>sohu</a></p> 
    我用的是jsp编程,我把纯html写在了字符串a里,让后调用javascript把jsp里的字符串a打印出来 
    document.write(‘《%=a%》’);可是我试了不行,/ “ ...好象都显示不出来了
     
      

  6.   

    If you try this
    <script language="javascript">
    var win=open("","_blank");
    var doc = win.document;
    doc.open();
    doc.write("<a href='http://sohu.net'>sohu</a></p>");
    doc.close();
    </script>You will know that this string can be written out. But You are going to have problems if the string contains newlines.Here is a suggestion, put the string in a hidden layer, like this
    <div id="dvHidden" style="display:none"><%=a%></div>Then when you are ready to write, try
    win.document.write(document.all('dvHidden').innerHTML);Good luck!