-
不要用innerHTMl改用innerText
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div id='a'>p</div>
<div id='b'>ss</div>
</body>
<script>
document.getElementById('a').innerText='這是通過text<hr/>修改的內(nèi)容'
document.getElementById('b').innerHTML='這是通過innerhtml<hr/>修改的內(nèi)容'
</script>
</html>
你會到通過innerText輸入的標(biāo)簽不會被編譯
-
服務(wù)端接收的時候,把關(guān)鍵字符,比如<>改成字符
例如< 符號變成 <