jiankeqcaf 发表于 2012-6-19 11:24:26

高手来,请教个问题 多行长字符串变量赋值

本帖最后由 jiankeqcaf 于 2012-6-19 11:27 编辑

一个id="neirong"的div里面是一篇文章的内容,获取这个id里面的innerhtml ,赋值给变量$str
$str=_IEGetObjById($oIE,"neirong").innerhtml
$str里面含有很多行的html代码,要把$str赋值给一个FCKeditor编辑器

js('var editor = FCKeditorAPI.GetInstance("FCKeditor1")')
js('editor.SetHTML(" '&$str&' ")')

Func js($script)
        $oIE.document.parentWindow.execscript($script)
EndFunc

现在的问题是因为$str是很多行的 且含有单双引号 空格( ) 无法成功给FCKeditor赋值
如果$str="<strong>123</strong><a href=www.baidu.com>baidu</a>"即只有一行html代码则可以给FCKeditor赋值成功,
请教 如何把多行的$str赋值给FCKeditor呢?

shqf 发表于 2012-6-19 12:25:51

试试把回车符去掉后再赋值给FCKeditor编辑器行不行:
$str=StringRegExpReplace($str, '[\n|\r]', '')

jiankeqcaf 发表于 2012-6-19 14:30:41

$str=StringReplace($str, '"',"");去双引号
$str=StringReplace($str, "'","");去单引号
在加上这些 就解决了 谢谢楼上帮助

xms77 发表于 2012-6-19 16:28:49

顶你一下,加油啊,伙计!
页: [1]
查看完整版本: 高手来,请教个问题 多行长字符串变量赋值