不想调用系统“查找”对话框。有一个“查找下一个”按钮和一个用于输入关键字的edit1,请教在Webbrowser如何实现“查找下一个”功能?

解决方案 »

  1.   

    Webbrowser 查找下一个网页吗?   
    那你重新用他的属性打开别的页面不可以么
    定义个数组
      

  2.   

    http://www.snook.ca/archives/mshtml_and_dec/creating_a_cust/script language="JavaScript">
    // on load create a textrange with everything in my 
    // editor object tbContentElement 
    var rng = dialogArguments.document.all.tbContentElement.
                   DOM.selection.createRange();// returns a calculated value for matching case and
    // matching whole words
    function searchtype(){
        var retval = 0;
      var matchcase = 0;
      var matchword = 0;
      if (document.all.blnMatchCase.checked) matchcase = 4;
      if (document.all.blnMatchWord.checked) matchword = 2;
      retval = matchcase + matchword;
      return(retval);
    }// find the text I want
    function findtext(){
      if (document.all.strSearch.value.length < 1) {
        alert("Please enter text in the \"Find what:\" field.");  } else {
        var searchval = document.all.strSearch.value;
        rng.collapse(false);
        if (rng.findText(searchval, 1000000000, searchtype())) {
          rng.select();
        } else {
          var startfromtop = confirm("Your word was not found.\nWould you 
                                        like to start again from the top?");
          if (startfromtop) {
            rng.expand("textedit"); // selects everything
            rng.collapse(); // collapse at the beginning
            rng.select(); // create the selection
            findtext(); // start again 
          }    }
      }
    }
    </script>you can also use IMarkupServices
    http://www.codeguru.com/cpp/i-n/ieprogram/article.php/c4373/for( ; ;)
    {
     // Find text
     hr = pPtr1->FindText( poSearchStr, 0, pPtr2, NULL ); if (hr == S_FALSE) // did not find the text
      break; IHTMLElement *pFontEl; // create FONT element with attributes for selection
     OLECHAR pchAttributes=0;
     hr=pMS->CreateElement(TAGID_FONT,
     L"COLOR=white STYLE=\"backgroundcolor:darkblue\"", &pFontEl); // Insert created element to context
     hr=pMS->InsertElement( pFontEl, pPtr1, pPtr2);// Continue searching
    pPtr1->MoveToPointer( pPtr2);
    }
      

  3.   

    谢谢热心人,我好像没说明白,不好意思,我说的是Edit和button在webbrowser的外面,并不是在网页里。
      

  4.   

    the Document Object Model is the same.
      

  5.   

    jiangsheng(蒋晟.Net[MVP]):
    我说的能够“查找下一个”,“查找第一个”我会的。
    你的说的代码,我执行有错误,能不能再费心帮解决一下,谢谢。
      

  6.   

    rng.collapse(); // collapse at the beginning
    this couse the selection to move on