weixin_33694620 2014-09-24 00:51 采纳率: 0%
浏览 108

IE中的换行问题

I have a textarea that I am trying to fill with a list of words which have been fetched by a php script through AJAX, but when the list is diplayed in the textarea, the linebreaks are converted to (what appear to be) spaces (causing all the words to be on one line).

In the php I have tried:

echo implode("
",$list); // and
echo implode("
",$list); 

and none of these pass workable linebreaks to the javascript. I have searched this site (and others), and the general solution seems to be to replace any occurance of with . I tried that using javascript, more or less like so:

textarea.innerHTML = ajax_response.replace('/
/g','
');

however, this doesn't solve the problem. Is there something I'm missing? As I say, most solutions I've found online suggest to try the replacement, but is there any other workarounds for IE?

Thanks :)

  • 写回答

2条回答 默认 最新

  • weixin_33727510 2014-09-24 00:57
    关注

    Try this:

    echo implode('\
    ', $list);
    

    You want the backslash in the result, not a technological new line.

    Additionally, a textarea is like an input. Use .value, instead of .innerHTML.

    textareaElement.value = ajax_response;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名