473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Search for or find a word within the page using javascript

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.createTextRange();


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 4611
acoder
16,027 Expert Mod 8TB
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
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...
1
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,...
4
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...
5
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...
3
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...
5
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...
5
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 -...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.