我试了可是不行呀,我把字符串从数据库里读出来写到了String a 里了 然后document.write('<%=a%>'); 提示有错误呀!
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"
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!
然后document.write('<%=a%>');
提示有错误呀!
<%=a%>
?with
document.write('<%=a%>');
if you have a newline inside String a, you will get an error: "Unterminated string constant"
然后html数据在jsp中的字符串a中,你们说应该怎么办呀!!!!!
<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!
为什么不性呢,报什么错,只要你的<%=a%>里面没有单引号就可以,
如果单引号、双引号都有,就不好半了