Home >Web Front-end >JS Tutorial >JS saving, reading, line wrapping, Json conversion error handling methods_javascript skills

JS saving, reading, line wrapping, Json conversion error handling methods_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:32:131316browse

Exception information: Unexpected token ILLEGAL

Let’s talk about the processing method first:
1. Save:

Copy code The code is as follows:

varcont=encodeURI($("#txtMessage_Content").val()).replace(/ /g,"brHH");

2. Read:
Copy code The code is as follows :

entity[i].Contents.replace(//,">").replace(/brHH/g ,"
")

Explanation:
The main idea is the substitution method.
JS seems to be unable to capture the text directly. Press Enter and encodeURI to capture it.
Copy code The code is as follows:

replace(//,">")

This sentence deals with JS injection
Copy code The code is as follows:

replace(/brHH/g,"
")

Here is replacing the above with Enter Replace and display
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn