Method 1:
Use the browser's internal converter to achieve conversion. The method is to dynamically create a container tag element, such as DIV, and set the string to be converted to the innerText of this element (supported by IE)||textContent (supported by Firefox) , and then return the innerHTML of this element, that is, get the string converted by HTML encoding, which can be reversed when displayed (actually, there is no need to go through conversion when displaying, and it can be displayed normally by assigning the value directly to the div).