ch4_examp2.htm

来自「javascript source code part1」· HTM 代码 · 共 26 行

HTM
26
字号
<HTML>
<BODY>
<SCRIPT LANGUAGE=JavaScript>
var myString = "Welcome to Wrox books. "
myString = myString + "The Wrox website is www.wrox.com. "
myString = myString + "Visit the Wrox website today. Thanks for buying Wrox"

var foundAtPosition = 0;
var wroxCount = 0;

while ( foundAtPosition != -1)
{
   foundAtPosition = myString.indexOf("Wrox",foundAtPosition);
   if (foundAtPosition != -1)
   {
      wroxCount++;
      foundAtPosition++;
   }
}

document.write("There are " + wroxCount + " occurrences of the word Wrox");

</SCRIPT>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?