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); }
那你重新用他的属性打开别的页面不可以么
定义个数组
// 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);
}
我说的能够“查找下一个”,“查找第一个”我会的。
你的说的代码,我执行有错误,能不能再费心帮解决一下,谢谢。
this couse the selection to move on