此方法会去除任何看起来像 HTML 脚本块的字符串。
语法
string.stripScripts();
返回值
返回修剪后的字符串。
例子
HTML
x
26
26
1
<html>
2
<head>
3
<title>Prototype examples</title>
4
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
5
6
<script>
7
function showResult() {
8
var str = 'a <a href="#">link</a> ' +
9
' <script> ' +
10
' alert("Hello!") ' +
11
' </script>';
12
13
var str = str.unescapeHTML();
14
alert( str);
15
alert (str.stripScripts() );
16
}
17
</script>
18
</head>
19
20
<body>
21
<p>Click the button to see the result.</p>
22
<br />
23
<br />
24
<input type = "button" value = "Result" onclick = "showResult();"/>
25
</body>
26
</html>
阅读剩余 78%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8845.html