</html>
<head>
<title>javascript</title>
<script type="text/javascript">
function fin(i)
{
if(window.find(i,true))
alert(i+"找到了");
else
alert("没有这个词");
}
</script>
</head>
<body>
<p>搜素下面文字</p>
<blockquote>
<hr>
今天天气真好,万里无云
<hr>
</blockquote>
<form>
<input type="text" name="a" value=" ">在这里输入要搜素的词</input>
<input type="button" name="b" value="搜素" onClick="fin(a.value)"></input>
</form>
</body>
</html>

解决方案 »

  1.   

    我只找到了这个东西,你的find方法在微软提供的资料中没有找到当然我的资料很老了findText--------------------------------------------------------------------------------DescriptionSearches for text in the document. Positions the start and end points of the range to encompass the search string. Syntax
    bFound = object.findText(sText [, iSearchScope] [, iFlags])Parameter Description 
    sText String specifying the text to find. 
    iSearchScope Optional. An integer indicating the direction to search from the starting point of the range. A positive integer indicates a forward search; a negative integer indicates a backward search. 
    iFlags Optional. A combination of one or more of the following flags indicating the type of search: 2 match whole words only. 
    4 match case. 
     Return ValueReturns true if the search text is found, or false otherwise. 
      

  2.   

    <script type="text/javascript">
    function FindText(text)
    {
    if (window.find) return window.find(text, true);
    var range = document.body.createTextRange();
    if (range.findText(text, -1))
    {
    range.scrollIntoView();
    range.select();
    return true;
    }
    return false;
    }function fin(i)
    {
    if (FindText(i))
    alert(i + "找到了");
    else alert("没有这个词");
    }
    </script>
    window.findText()是ff里的,ie中得用TextRange.findText()
      

  3.   

    window.findText()是ff里的,ie中得用TextRange.findText()