标题:==>关于转义字符的问题,谢谢先^_^
只看楼主
cjh
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2005-3-31
 问题点数:0 回复次数:7 
==>关于转义字符的问题,谢谢先^_^
为什么把document.form.input.value赋给变量的时候,会自动把“&lt;“转换成“<”、"&gt;"转换成">"呢?如何能禁止这样呢? 情况是这样的: 我用下面这个代码是页面显示内容是:<aadada>asda <script> function mr() { var cjh = "&lt;aadada&gt;asda"; Editor.document.body.innerHTML = cjh ; } function initEditor() { Editor.document.designMode="on"; Editor.document.open(); initHTML = ""; Editor.document.write(initHTML); Editor.document.close(); mr(); Editor.document.body.style.fontFamily = "Courier New","宋体"; Editor.document.body.style.fontSize ="12px"; } </script> <body onload="initEditor()"> <iframe id="Editor" Name="Editor" width=99% height=400 marginwidth="0" marginheight="0"></iframe> </body> 而用下面这个代码是页面显示内容是:asda <script> function mr() { var cjh = document.form1.content.value ; Editor.document.body.innerHTML = cjh ; } //初始化编辑器 function initEditor() { Editor.document.designMode="on"; Editor.document.open(); initHTML = ""; Editor.document.write(initHTML); Editor.document.close(); mr(); Editor.document.body.style.fontFamily = "Courier New","宋体"; Editor.document.body.style.fontSize ="12px"; } </script> <body onload="initEditor()"> <iframe id="Editor" Name="Editor" width=99% height=400 marginwidth="0" marginheight="0"></iframe> <form name="form1"><input name="content" type="hidden" id="content" value="&lt;aadada&gt;asda"></form> </body> 一个是直接赋值,一个是通过隐藏的输入框赋值,结果却差别这么大? 大家救命啊

[此贴子已经被作者于2005-4-27 16:55:38编辑过]

搜索更多相关主题的帖子: 字符 转义 
2005-04-27 16:51
surnfu
Rank: 1
等 级:新手上路
帖 子:102
专家分:0
注 册:2005-3-21
得分:0 
太奇怪了

http://
2005-04-27 17:18
bingxue2332
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:446
专家分:0
注 册:2004-11-6
得分:0 
这里有些是html的保留字符

你使用dw做网页时就可以看到

2005-04-27 18:55
cjh
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2005-3-31
得分:0 

问题已经解决

谢谢大家关心:)


从现在起,做一个自己喜欢的人!
2005-04-27 22:15
surnfu
Rank: 1
等 级:新手上路
帖 子:102
专家分:0
注 册:2005-3-21
得分:0 
还没有用过dw   都是用记事本    呵  太落后了

http://
2005-04-28 00:10
bingxue2332
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:446
专家分:0
注 册:2004-11-6
得分:0 
用  Visual InterDev

2005-04-28 12:26
kingcat_1985
Rank: 1
等 级:新手上路
帖 子:207
专家分:0
注 册:2004-11-7
得分:0 
以下是引用cjh在2005-4-27 22:15:12的发言:

问题已经解决

谢谢大家关心:)

可是我还是不明白啊~~~可以解释一下吗?


我是菜鸟~~~   各位大哥要照住小弟我啊~~~
2005-04-28 12:32
wanglong202
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2005-4-22
得分:0 
我也觉得奇怪,这段代码是这样运行的,当页面内容显示后,才开始载入onload 也就是说函数得到的document.form1.content.value 的值是通过http转化的吗,等待正确答案
2005-04-28 13:58



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-16863-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.522361 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved