Home >Web Front-end >JS Tutorial >js single quote transfer method_javascript skills

js single quote transfer method_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:51:111108browse
Copy code The code is as follows:

<script> <br><br>function showMessage(msg) { <br>alert(msg) <br>} <br></script>


')">


When the value taken out from the bean in the above code is a single quote, a js error will be reported when loading the page. This can be solved using the following method.
Copy code The code is as follows:

<script> <br><br><br><br><br></script>


" />
< /form>




function showMessage(){
var msg=document.formName.msg.value;
alert(msg)
}
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