admin 管理员组

文章数量: 1087564

Using node.innerHTML = "abcxyz <[email protected]>"; makes the browser display something just the “abcxyz” part – the rest is seemingly ignored because of the angle brackets (<>). How to ensure they show on the page?

Using node.innerHTML = "abcxyz <[email protected]>"; makes the browser display something just the “abcxyz” part – the rest is seemingly ignored because of the angle brackets (<>). How to ensure they show on the page?

Share Improve this question edited Dec 1, 2024 at 12:45 dumbass 27.3k4 gold badges38 silver badges74 bronze badges asked Jul 8, 2009 at 11:28 AbhimanyuAbhimanyu 4,9177 gold badges35 silver badges45 bronze badges 0
Add a ment  | 

5 Answers 5

Reset to default 10

Actually, the content is still there, but the browser interprets it as unknown tag, that is, it does not display anything. Look at the generated page source (in FF, e.g., mark all text and use "Selection source" from the context menu).

Try quoting the brackets:

obj.innerHTML = "abcxyz <[email protected]>".replace (/</g, "&lt;")

This, however, will replace all <. If you want to embed other HTML, too, you will have to keep track on what you already encoded and what not.

Cheers,

HTML encode your string or use HTML entities such as &lt;

In HTML, a literal "<" is represented as "&lt;" and a literal ">" is represented as "&gt;". See HTML 4.01 section 5.3.2.

I would try this: unescape('abcxyz %3Cabc...

You need to escape < and > in string.

本文标签:

Error[2]: Invalid argument supplied for foreach(), File: /www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm, Line: 58
File: /www/wwwroot/roclinux.cn/tmp/route_read.php, Line: 205, include(/www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm)
File: /www/wwwroot/roclinux.cn/tmp/index.inc.php, Line: 129, include(/www/wwwroot/roclinux.cn/tmp/route_read.php)
File: /www/wwwroot/roclinux.cn/index.php, Line: 29, include(/www/wwwroot/roclinux.cn/tmp/index.inc.php)