window.find in IE

Hello,

I was wondering if there is a function that has the same result as window.find (in Netscape) in Internet Explorer? For some reason the window.find function does not work in Internet Explorer 5.0.. Thanks!

Ian
LVL 1
ianpughAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ianpughAuthor Commented:
Adjusted points to 100
0
PBallCommented:
A workaround in IE...
possibly...TextRange object or
enclose your document in a DIV and you can use the DIV id and get the innerText/innerHTML property of it and find the string in there using String object search, indexOf, lastIndexOf methods or VBScript instr.
0
ianpughAuthor Commented:
Adjusted points to 200
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

giant_lizard_of_deathCommented:

bFound = oTextRange.findText(sText, [, iSearchScope] [, iFlags]);

oTextRange = object, the text range duh
sText      = text to be found
iSearchScope = #of chars to search from the starting point of oTextRange
iFlags     = (2 = match whole word)
             (4 = case sensitive)
   <i'm guessing iFlags is a bitfield>

Try this code fragment (shamelessly stolen from MSDN docs):

var oRange =
   document.body.createTextRange();

// record current position
var sBookmark = oRange.getBookmark();

// go to "foo"
oRange.findText('foo');

// go back to sBookmark
oRange.moveToBookmark(sBookmark);
0
ianpughAuthor Commented:
Adjusted points to 245
0
ianpughAuthor Commented:
It does not seem to work right!
0
kmartin7Commented:
The following is set up to sork in a frameset, but can be configured to work w/o a frameset.  

It works 2 ways - 1) select a word in the second frame by drag-and-drop method, then click on "Find in the top frameset , or 2) First click on "Find" in the top frameset to launch a prompt in ehich to type in the search string.

Fset.htm:
<HTML>
<HEAD>
<TITLE>IE_Find</TITLE>
</HEAD>
      <FRAMESET ROWS="45, *">
            <FRAME SRC="find.htm" NAME="find">
            <FRAME SRC="text.htm" NAME="text">
      </FRAMESET>
</HTML>

find.htm:

<HTML>
<HEAD>
<TITLE>Find in IE</TITLE>
</HEAD>
<BODY BACKGROUND="" BGCOLOR="#ffffff" TEXT="#000000" LINK="#0000ff" VLINK="#800080" ALINK="#ff0000">
<CENTER>
<a href="javascript:FD983r={x:function(){
var%20r,i,s=parent.frames[1].document.selection.createRange().text;
      if(!s)s=prompt('Type in the string you are searching for:','');
            if(s){r=parent.frames[1].document.body.createTextRange();
            for(i=0;r.findText(s);i++){r.execCommand('BackColor','','#FF0080');
      r.collapse(false)};if (i==0){
            alert('The string \'' + s + '\' is not found in this document.');
}
      else{
            alert('There are ' + i + ' instances of the string: \''+s+'\'.')}}}
};
      FD983r.x();">Find</a>
</CENTER>
</BODY>
</HTML>

text.htm:
   
<html>
<head>
<title>Text</title>
</head>
<body>
<p>
This is a test find page (from E-E homepage).

Welcome to Experts Exchange, the Internet's largest network of qualified technology experts. EE offers its members fast, free answers to questions in over 80 computer technology categories.  
   
Windows 95  
General
Setup
Windows 98


Windows NT  
General
Setup
NT 5


Windows Etc.  
3.x General
3.x Setup
Office-Word-Excel
Outlook


Databases  
Access
Fox Pro
General
MS-SQL
Oracle
Sybase


Internet  
General
Newbies
Browsers
Hot URLs

 Computers  
General
Newbies
Year 2000
Games


PDA  
Palm Pilot
Windows CE


Groupware  
Lotus Notes


Hardware  
General
Modems
Printers
HP Printers
HP Scanners
Scanners


Macintosh  
Applications
Communications
System


 Programming  
C
C++
Delphi
Java
JavaScript
Macintosh
MFC
OWL
OS/2
Pascal
Perl
Unix
Windows
Visual Basic
VB Databases
VB Controls


WWW Dev.  
Front Page
Authoring
CGI
HTML
Images
XML
ASP
ColdFusion
PHP
 Unix  
General
Setup


Linux  
General
Setup


Networking  
Linux
Macintosh
NetWare
OS/2
Unix
Windows 95
Windows NT


OS/2  
Applications
General
Setup


Graphics  
Fonts
General
Photoshop


EE Support  
Experts Exchange

More topics...
</body>
</html>

If you need more help, let me know.

Kurt
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ianpughAuthor Commented:
Thanks!
0
ianpughAuthor Commented:
Kurt--

Is there a way to clear the area before you do another search? So only the current criteria are highlited? Thanks!

Ian
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.