How to stop an html TEXTAREA from decoding html entities

后端 未结 6 1275
眼角桃花
眼角桃花 2021-01-01 12:46

I have a strange problem:

In the database, I have a literal ampersand lt semicolon:

<div  

whenever its printed into a html

6条回答
  •  盖世英雄少女心
    2021-01-01 13:08

    I had the same problem and I just made two replacements on the text to show from the database before letting it into the text area:

    myString = Replace(myString, "&", "&")
    myString = Replace(myString, "<", "<")
    

    Replace n:o 1 to trick the textarea to show the codes. replace n:o 2: Without this replacement you can not show the word "" inside the textarea (it would end the textarea tag).

    (Asp / vbscript code above, translate to a replace method of your language choice)

提交回复
热议问题