In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "what are the special characters commonly used in HTML". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
HTML special symbol codes include many kinds of unicode, hexadecimal codes (hex code), html entity codes (entity code), and html entities (html entity) as we know them, and corresponding css code for use in the css content attribute.
You can insert hexadecimal codes (hex code), html entity codes (entity code) or html entities (html entity) directly into the HTML tag. When used in the css content attribute, you should use the corresponding css code.
It is important to note that some symbols are displayed differently depending on the font.
In project applications, there are times when you need to convert html and html code. Here are two ways to convert each other:
JavaScript Code:
Function html_encode (str) {var s = ""; if (str.length = = 0) return ""; s = str.replace (/ & / g, "&"); s = s.replace (/ / g, ">"); s = s.replace (/ / g, ""); s = s.replace (/\'/ g, "& apos;"); s = s.replace (/\ "/ g,") S = s.replace (/\ nCompact g, "
"); return s;} function html_decode (str) {var s ="; if (str.length==0) return ""; s = str.replace (/ & / g, "&"); s = s.replace (/ / g, ">"); s = s.replace (/ / g, ""); s = s.replace (/ & apos;/g, "\"); s = s.replace (/ "/ g,"\ ") S = s.replace (/
/ g, "\ n"); return s;}
Conversion can also be achieved using DOM's innerHTML and textContent by dynamically creating a container tag element, such as DIV, setting the string to be converted to the element's innerText, and then returning the element's innerHTML, which is the HTML-encoded string.
JavaScript Code:
Function html_encode (html) {return document.createElement ('div') .appendChild (document.createTextNode (html)) [xss_clean] [xss_clean];} function html_decode (html) {var a = document.createElement (' div'); a [XSS _ clean] = html; return a.textContent;}
This is the end of the content of "what are the special characters commonly used in HTML". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
This article introduces the knowledge of "how to use Go to write command-line tools". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Wechat
About us
Contact us
Product review
car news
thenatureplanet
More Form oMedia:
AutoTimes.
Bestcoffee.
SL News.
Jarebook.
Coffee Hunters.
Sundaily.
Modezone.
NNB.
Coffee.
Game News.
FrontStreet.
GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.