Prototype extractScripts() 方法

描述

Prototype extractScripts()方法操做使用例子 - 這種方法提取字符串中的任何腳本塊的內容,並返回一個字符串數組javascript

這種方法提取字符串中的任何腳本塊的內容,並返回一個字符串數組.html

語法:

ScriptString.extractScripts();

返回值:

  • 返回一個字符串數組.

例子:

<html>
<head>
<title>Prototype examples - www.yiibai.com</title>
<script type="text/javascript" 
   src="/javascript/prototype.js">
</script>
<script>

function showResult(){

  var str = 'other HTML... <script>2 + 2</script>';
  alert( str.extractScripts());

}

</script>
</head>

<body>

  <p>Click the button to see the result.</p>
  <br />
  <br />
  <input type="button" value="Result" onclick="showResult();"/>

</body>
</html>

以上獲得結果值:java

[2 + 2 ]
友情連接 prototype博客
相關文章
相關標籤/搜索