473,581 Members | 2,786 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Search for or find a word within the page using javascript

5 New Member
There is two frame in my form.In d first frame there is a text box,and i give some word in the text box.I want to search the word from a file from the location(http://45.12.09.31...........) and if the word is found any file of that location,
the file will display in second frame.
main problem is arise in the following line.
txt = s.document.body .createTextRang e();


here the code is :
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4. <meta http-equiv="Content-Language" content="en-us">
  5. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  6. <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
  7. <meta name="ProgId" content="FrontPage.Editor.Document">
  8. <title>New Page 1</title>
  9. </head>
  10.  
  11. <body>
  12.  
  13. <p align="center">&nbsp;</p>
  14.  
  15. <p align="center">&nbsp;</p>
  16.  
  17. <p align="center"><b><u><span style="background-color: #FFFFFF"><font face="Copperplate Gothic Bold" size="6" color="#000080">Find
  18. The Page</font></span></u></b></p>
  19. <p align="center">&nbsp;</p>
  20. <p align="center">&nbsp;</p>
  21. <p align="center">&nbsp;</p>
  22.  
  23.   <p align="center">
  24. &nbsp;
  25.   </p>
  26.  
  27. <Script language = JavaScript>
  28. var year = new Array("2007");//,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018
  29. var month  = new Array("May");//,"Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
  30.  
  31.  
  32. var i = 0;
  33. var i1 = 0;
  34. var IE4 = (document.all);
  35. var n   = 0;
  36.  
  37. function findInPage1(str) 
  38. {
  39.   var  i2,txt,found;
  40.  
  41. for(i=0;i<year.length;i++)
  42.  {
  43.   for(i1=0;i1<month.length;i1++)
  44.   {
  45.    s="http://10.50.110.59:1977/archive/sysdoc1_";
  46.     s+=month[i1];
  47.     s+=year[i];
  48.     s+=".htm";
  49.     //parent.word_f2.location.href=s;
  50.  
  51.  
  52.     if (str == "")
  53.     return false;
  54.  
  55.      if (IE4)
  56.       {
  57.     //txt = window.document.body.createTextRange();
  58.     //txt = parent.word_f2.document.body.createTextRange();
  59.    txt = s.document.body.createTextRange();
  60.  
  61.  
  62.     // Find the nth match from the top of the page.
  63.  
  64.     for (i2 = 0; i2 <= n && (found = txt.findText(str)) != false; i2++) {
  65.       txt.moveStart("character", 1);
  66.       txt.moveEnd("textedit");
  67.      }
  68.  
  69.      if (found) {
  70.     // document.write(s);
  71.      parent.word_f2.location.href=s;
  72.        txt.moveStart("character", -1);
  73.        txt.findText(str);
  74.        txt.select();
  75.        txt.scrollIntoView();
  76.       n++;
  77.     }
  78.  
  79.     else {
  80.       if (n > 0) 
  81.       {
  82.        //document.write(qqq);
  83.  
  84.         n = 0;
  85.         findInPage1(str);
  86.       }
  87.  
  88.       // Not found anywhere, give message.
  89.  
  90.       else
  91.       //{
  92.       //document.write(wewe);
  93.  
  94.         alert("Not found.");
  95.        // }
  96.     }
  97.     }
  98.       return false;
  99.  
  100.  
  101.   }//for loop1
  102.  }//for loop2
  103. }
  104.  
  105.  
  106. </script>
  107.  
  108. <form name="search" onSubmit="return findInPage1(this.string.value);">
  109. <p align="center">
  110. <font size=3 face="t"><b><input name="string" size=15 onChange="n =  0;"></b></font>
  111.  <span style="background-color: #00FFFF">
  112. <input type="submit" value="Search" style="font-size: 12pt; font-family: Times New Roman; font-weight: bold; color: #0000FF"></span></form>
  113.  
  114.  
  115. </body>
  116.  
  117. </html>
  118.  

Plz help.thanking you.
Dec 28 '07 #1
1 4636
acoder
16,027 Recognized Expert Moderator MVP
Check out this link and see if it helps solve your problem.

PS. I've changed the thread title.
Dec 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2267
by: JF Potvin | last post by:
Hi ! I'm new to Perl and this group so any help is welcome. I've look around the groups a lot but I can't seems to find what I need. I have to do a script that connects to a specific web page and search it's source code for some words. Now, the script is able to connect to the page, print the source on screen but when I try to search, it...
1
8712
by: Les Juby | last post by:
A year or two back I needed a search script to scan thru HTML files on a client site. Usual sorta thing. A quick search turned up a neat script that provided great search results. It was fast, returned the hyperlinked page title, filename, and the body txt (30 preceding and following words) in context with the search word highlighted. ...
4
1394
by: Rob Meade | last post by:
Lo all, Ok - just spotted another problem I'm going to have. All of the rows for the page content in the database contain formatting ie, <b>some bold text</b> This will cause me a problem initially as if I wanted to search for <company name> the SQL statement
5
1509
by: Deryck | last post by:
Hi, I am working on an e-commerce site. It uses a CMS. One requirement is to have a static off-line version so that the company's sales reps can visit customers and take orders on a laptop without having to go online (I'm told that the rep's customers don't always appreciate being asked for a phone line to be tied up and that sometimes they...
3
2013
by: Russell | last post by:
Hey, ok i have numerous tables to search through for a 'site search'. some of the searchble fields have html embeded within so after some quick referencing, saw I can use the regExp function to strip out all the HTML leaving only the raw text. (done and works a treat) My issue is:
5
5030
by: vonclausowitz | last post by:
Repost from an VB group. Hi All, I'm looking for a way to search for multiple words in a database. There is however one but. The words have to be within a certain range of each other. For example I would like to find records which contain the word MALE and within for example 10 words of it the word BROWN.
5
1547
by: kirpi | last post by:
In order to instant retrieve a word definition, I let a javascript add the word to the search url of various sites. Example: for the word "word" I create: - http://en.wikipedia.org/wiki/Word - http://www.google.it/search?q=define%3Aword - http://www.answers.com/word and so on. There is a good German online dictionary, www.pons.de/, for...
0
2069
by: | last post by:
I have a question about spawning and displaying subordinate list controls within a list control. I'm also interested in feedback about the design of my search application. Lots of code is at the end of this message, but I will start with an overview of the problem. I've made a content management solution for my work with a decently...
0
7882
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7808
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6564
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3835
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1410
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1145
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.