您的位置:首页 > 其它

使用document.write需要注意的事项

2012-08-22 08:40 344 查看
document.write里面的字符串不能含有\n 否则将会帮错 如:

在php文字写这样的代码:

<?php

$sContent=" <tr>

<td>系统名称</td>

<td>当前值</td>

</tr>";

document.write($sContent)

这样javascript将会报错 在此之前应将\n清理掉

大家可以写一个函数过滤掉\n:

function filterLb($sContent){

$arrLine=explode($sContent);

$sContent='';

foreach($arrLine as $sValue){

$sContent.=$sValue;

}

return addslashes($sContent);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: