开发者

Remove all content between <script type="JavaScript">abcd</script> tags

I want to remove all things or content between <script>want to remove</script> I have very small amount of knowledge about php & java script so please give me a complete codes I have no idea how to use php or JavaScript coding to remove content between <tags></tags>

I found this box and copy in my website they remove all tags but I not want this I want only remove content between tags. Please any one modify this box or script to remove content between <tags></tags> or give me other script.

<script type="text/javascript">

// Strip HTML Tags (form) script- By JavaScriptKit.com (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// This notice must stay intact for use

function stripHTML(){
var re= /<\S[^><]*>/g
for (i=0; i<arguments.length; i++)
arguments[i].value=arguments[i].value.replace(re, "")
}

</script>

<form>

<textarea name="data1" style="width: 400px; height: 100px开发者_开发知识库"></textarea><br />
<input type="button" value="Remove any HTML tags" onClick="stripHTML(this.form.data1)">
</form>


you could try: document.getElementsByTagName('script')[0].innerHTML = '';


According to your code block you posted, it seems that you would like to strip script tags from the value of a form element (e.g. a textarea). Sanitizing user input on client side is generally considered to be a bad idea, because this kind of security measure can be easily bypassed. A better solution would be stripping the script tags from the posted data on the server side.

Here is an example in php:

$data = $_POST['fieldname'];

$outputData = strip_tags($data, array(/* here you can specify the allowed html tags, all others will be stripped */);

echo $output;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜