document.write('<p><a href="http://sohu.net">sohu</a></p>');

解决方案 »

  1.   

    我试了可是不行呀,我把字符串从数据库里读出来写到了String a 里了
    然后document.write('<%=a%>');
    提示有错误呀!
      

  2.   

    why can't you just do
    <%=a%>
    ?with 
    document.write('<%=a%>');
    if you have a newline inside String a, you will get an error: "Unterminated string constant"
      

  3.   

    不行,我在给一个隐藏桢的东西负值必须用document.write();
    然后html数据在jsp中的字符串a中,你们说应该怎么办呀!!!!!
      

  4.   

    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!
      

  5.   

    楼上的厉害啊,五星级!document.write('<p><a href="http://sohu.net">sohu</a></p>');
    为什么不性呢,报什么错,只要你的<%=a%>里面没有单引号就可以,
    如果单引号、双引号都有,就不好半了