Last active
August 29, 2015 14:06
-
-
Save shenqihui/5832b4a55388c874bd6e to your computer and use it in GitHub Desktop.
escape any html tap. 转义部分tap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('textarea') | |
.val() | |
.replace(/<([/^<>]*?((script)|(style)|(link)|(img)|(object)|(embed)|(textarea)|(input))[^<>]*?)>/g,"<$1>") | |
.replace(/\n/g,"<br>"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<textarea name="" id="" cols="30" rows="10"> | |
<script>alert('测试');</script> | |
<img src="http://www.baidu.com/img/bd_logo.png" alt=""> | |
<p>这是P标签</p> | |
<div>这是div标签</div> | |
<style>/*这个是style*/</style> | |
<link rel="stylesheet" href="http://www.baidu.com"> | |
</textarea> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment