带有回车和换行符的javascript错误
javascript error with carriage return and newline
我在Java中有以下字符串:
"this is text1'r'nthis is text2'r'nthis is text3"
我将'r'n
替换为<br/>
,如下所示:
String temp = "this is text1'r'nthis is text2'r'nthis is text3"
temp = temp.replaceAll("['r'n]+", "<br/>");
生成以下字符串:"is text1 this is text2 this is text3"
现在,我想把它发送到JavaScript元素,如下所示:
var desc_str = "<%=temp%>";
document.getElementById('proc_desc').value = desc_str;
Java的输出很好,但在传递到HTML元素后,我收到了JavaScript错误"unterminated String literal",我找不到线索,请帮忙。
听起来您还没有从String中获得所有换行符。
你可能会发现这篇文章很有帮助:如何将字符串中的所有换行符替换为<br/>标签?
相关文章:
- JavaScript错误:Microsoft JScript运行时错误:应为对象
- 将字符串拆分为数组时出现JavaScript错误
- 处理JSON字符串会导致JavaScript错误
- 使用AJAX在剑道网格中分组时出现Javascript错误
- Ajax对web URL的调用导致javascript错误
- 为什么当我尝试在Ionic中使用列表时会出现此JavaScript错误
- 可以't解决Javascript错误
- django出现神秘的javascript错误
- JavaScript错误无效的限定符
- 使用主题运行时portlet liferay时出现Javascript错误
- 绑定函数时在IE7中未实现Javascript错误
- Javascript错误:未捕获引用错误:未定义编辑
- eventListener出现JavaScript错误
- sharepoint站点的internet explorer中出现Javascript错误
- LoadControl HttpCompileException自定义服务器控件JavaScript错误
- 销毁Bootstrap popover时出现Javascript错误
- 无法加载Javascript错误XMLHttpRequest
- 使用JSON.parse时出现无效字符javascript错误
- 修复Javascript错误
- 模板字符串上的netbeans javascript错误(backticks)