IE9使用html标签设置textarea的innerHTML [英] IE9 set innerHTML of textarea with html tags

查看:160
本文介绍了IE9使用html标签设置textarea的innerHTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个字段

在IE9中,以下行给我错误"SCRIPT601:未知的运行时错误" //选项1. document.getElementById('code').innerHTML ='some text';

In IE9 the following line gives me the error 'SCRIPT601: Unknown runtime error ' //option 1. document.getElementById('code').innerHTML = 'some text';

当我将行更改为以下内容时,错误消失并且似乎可以正常工作(辅助空值): //选项2. document.getElementById('code').innerHTML ='';

The error disappears and it seems to work (assiging empty value) when I change the line to: //option 2. document.getElementById('code').innerHTML = '';

我尝试了这个: //选项3. document.getElementById('code').innerHTML = escape('some text');

The I tried this: //option 3. document.getElementById('code').innerHTML = escape('some text');

但是随后HTML被转义了,那不是我想要的,我希望将这个确切的字符串放置在文本框中.

but then the HTML gets to be escaped and thats not what I want, I want this exact string to be placed in the textbox.

在Chrome和Firefox中,选项1中的代码可以正确运行.

In Chrome and Firefox the code in option 1 does run correctly.

该如何解决?

推荐答案

您应设置

You should set the value property.

这篇关于IE9使用html标签设置textarea的innerHTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆