JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 8th, 2001, 10:21 AM
Helios Helios is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: Chicago, USA
Posts: 73 Helios User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
The following code is not mine and I can't remember for the life of me where I got it but I need help modifying it. What it does is takes a keyword from a form and searches the text on the page the script resides on and highlites any matches.

I want to put the script in a frame at the top of the page and have it search the text in the main frame but I dont know how to modify it so that it will do this. Any help will be much appreciated.

[CODE]
<script language="JavaScript">

var NS4 = (document.layers);
var IE4 = (document.all);

var win = window;
var n = 0;

function findInPage(str) {

var txt, i, found;

if (str == "")
return false;

if (NS4) {

if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;

if (n == 0)
alert("Not found.");
}

if (IE4) {
txt = win.document.body.createTextRange();

for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}

if (found) {
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
}

else {
if (n > 0) {
n = 0;
findInPage(str);
}

else
alert("Not found.");
}
}

return false;
}

</script>

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > javascript search; target main frame...

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap