如何在textarea中有不同的字体颜色? [英] How do I have different font colors in a textarea?

查看:801
本文介绍了如何在textarea中有不同的字体颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要在文本区域中更改字体颜色,因为我在输入特定的关键字,如Visual Studio。

I want the font color to change in a textarea as I type in specific keywords, like in Visual Studio.

我没有看到这个地方,不知道这是否可以用HTML和JavaScript。

I have not seen this anywhere, so I don't know if this is possible with HTML and JavaScript.

有没有人看到这样的东西?或者知道如何编写它?

Has anyone seen anything like this? Or know how to write it?

推荐答案

Textarea是一个标准的HTML元素,因此是在时间的黎明之后发明的。不幸的是,这意味着它的外观和功能有限。

Textarea is a standard HTML element and so was invented just after the dawn of time. Unfortunately this means it is limited in it's appearance and functionality.

根据我所知,更改特定词语的颜色是不可能的。但是,解决这个问题的方法是在页面中嵌入一个iFrame。这样,您可以将iFrame内容视为另一个网页,并使用CSS对其进行样式化。

Changing the colours of specific words is not possible as far as I know. However a way to get around this would be to have an iFrame embedded in the page. That way, you can treat the iFrame content as another web page and style it using CSS.

Yahoo RTE FCKEditor 轻量级RTE 以这种方式工作。

The Yahoo RTE, the FCKEditor and the Lightweight RTE works in this way.

另一个不使用iFrame的选项是Stack Overflow上使用的编辑器,称为WMD。这些文件是此处

Another option, which does not use an iFrame is the editor used here on Stack Overflow, known as the WMD. The files are here.

这篇关于如何在textarea中有不同的字体颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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