/    Sign up×
Community /Pin to ProfileBookmark

IE/NS Compatible Find in Page code

There are two scripts, I only need one of them for off-line use only in a html file
So I have added both scripts to my song lists. But I must use different Browsers for either one to work.Try it to see what I am looking for.

<head>
<title>Search Page</title>
</head>
<body bgcolor=”#ffffff” text=”#004080″ link=”#008040″ vlink=”#ff8000″ alink=”#ff0000″>

<DIV align=left><A
href=”javascript:wR6dDs6S=prompt(‘Find%20any%20of%20these%20words%20in%20page…’,”);

if(wR6dDs6S!=null){void(w81dJs6S=wR6dDs6S.split(‘%20’));for(i=0;i<w81dJs6S.length;i++){if(find(w81dJs6S[i]))%20{break}}}else{void(null)}”><FONT color=#0000ff size=+1>Find in Page</FONT></NOBR></A> &nbsp;&nbsp;&nbsp; <A href=”javascript:find()”><FONT color=#0000ff
size=+1>Find Next</FONT></A></DIV>
<br> Song files would be here. Type one of these words to check it out.
<br>
The first script opens in IE but doesn’t locate anything.
<br>
The second script opens in Netscape and will search for even a part of a word.<p>
I am looking for a page search compatible to IE and NS, and to search only for words not a part of one.</body>

</html>
Your help is greatly appreciated, Thanks.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@pyroFeb 13.2004 — Try something like this:

&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Simple search demo&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;

&lt;style type="text/css"&gt;
.search {
color: #666;
background-color: #eee;
}
&lt;/style&gt;

&lt;script type="text/javascript"&gt;
function searchDiv(frm) {
obj = document.getElementsByTagName("body")[0];
//initialize
re = new RegExp('&lt;span class="search"&gt;(.*?)&lt;/span&gt;', "gi");
str = obj.innerHTML.replace(re,"$1");
obj.innerHTML = str;
//find words
re = new RegExp("\b("+frm.searchval.value+")\b", "gi");
str = obj.innerHTML.replace(re,'&lt;span class="search"&gt;$1&lt;/span&gt;');
obj.innerHTML = str;
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="searchbox"&gt;This is some sample text. This is more sample text.&lt;/div&gt;
&lt;form action="" onsubmit="searchDiv(this); return false;"&gt;
&lt;p&gt;&lt;input type="text" name="searchval"&gt;
&lt;input type="submit" value="Search"&gt;&lt;/p&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@jdaviaauthorFeb 13.2004 — Thanks Pyro

I tried it in NS 4 NS6 and IE5

It brought up the form in IE and NS6 but no find.

I thought you had it in NS4, but what it opened was this:

Directory listing of /C|/NETSCAPE

Up to higher level directory

~temp00.html 1018 bytes Thu Feb 12 22:11:46 2004 Hypertext Markup Language

N6Setup.exe 241 Kb Tue Dec 26 01:30:52 2000 Binary Executable

Netscape 6/ Tue Dec 26 02:12:56 2000 Directory

I found some code that works that I won't use, because it is so long, that it makes the code page twice as long as my song list.

Incidently the code I posted earlier was from a Bookmarklet from www.bookmarklets.com
×

Success!

Help @jdavia spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...