scriptタグの範囲を削除する

書式

resultStr = str.stripScripts()

str : タグを削除したい文字列
resultStr : タグが削除された文字列

説明

HTML, XHTML, XMLデータ内のscriptタグで囲まれた範囲を削除するにはstripScripts()メソッドを使います。

サンプルコード [実行]

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="main.css" type="text/css" media="all">
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript"><!--
window.onload = function ()
{
var tagText = "<p>テキスト:<script>alert(123);</script></p>";
$("result").innerText = tagText.stripScripts();
$("result").textContent = tagText.stripScripts();
}
// --></script>
</head>
<body>
<h1>scriptタグブロックを削除する</h1>
<div id="result"></div>
</body>
</html>