Go Back  PPRuNe Forums > Misc. Forums > Computer/Internet Issues & Troubleshooting
Reload this Page >

Adding search box to HTML document

Wikiposts
Search

Notices
Computer/Internet Issues & Troubleshooting Anyone with questions about the terribly complex world of computers or the internet should try here. NOT FOR REPORTING ISSUES WITH PPRuNe FORUMS! Please use the subforum "PPRuNe Problems or Queries."

Adding search box to HTML document

Thread Tools
 
Search this Thread
 
Old 15th March 2023 | 16:25
  #1 (permalink)  
Thread Starter
25 Anniversary
 
Joined: Jan 1999
Posts: 1,377
Likes: 174
From: England
Adding search box to HTML document

Can any coding experts shed light on how to add a search box at the top when compiling an HTML document? There are plenty of suggested code sequences on the internet but with my very limited knowledge of coding I don't know which to use and I can't make any of them actually work. Viewing page source on other web pages for clues is too confusing and so doesn't help. If there is a simple solution I just need the HTML code and guidance as to where it should be inserted. Would it be between </head> and <body> ?

Thanks for info.

Discorde is offline  
Reply
Old 15th March 2023 | 18:11
  #2 (permalink)  
 
Joined: Sep 2008
Posts: 5,691
Likes: 24
From: Blighty
I don't recall having seen anything going after </head> and before <body>
I'd stick it somewhere between <body> and </body>
davidjohnson6 is offline  
Reply
Old 16th March 2023 | 00:07
  #3 (permalink)  
10 Anniversary
 
Joined: Jan 2012
Posts: 395
Likes: 18
From: anywhere
It's just a simple html form that is either processed by some server side code in a file on your server or runs a javascript function that searches the document or the web.

Put it anywhere inside the <body> that you like.
Prop swinger is offline  
Reply
Old 16th March 2023 | 11:03
  #4 (permalink)  
Community Builder
20 Countries Visited
20 Anniversary
 
Joined: Mar 2002
Aviation Qualifications: CPL
Posts: 3,392
Likes: 324
From: near an aeroplane
Is it the page itself that you want to search? Or do you want to search the internet? I have used a Google form on my own site that enables you to search a specified website. See here for the details: https://programmablesearchengine.google.com/about/
Jhieminga is offline  
Reply
Old 16th March 2023 | 21:49
  #5 (permalink)  
Thread Starter
25 Anniversary
 
Joined: Jan 1999
Posts: 1,377
Likes: 174
From: England
Thanks Jhieminga. I should have been more specific - initially I wanted a search box to find text in a particular html doc and then if that worked add boxes in other items on my website.

I tried the Google code you suggested - the box appeared OK on the web page but returned 'No results' for any of the words I entered even though they featured in the text. Also lots of non-relevant links to ads appeared.
Discorde is offline  
Reply
Old 17th March 2023 | 08:22
  #6 (permalink)  
Community Builder
20 Countries Visited
20 Anniversary
 
Joined: Mar 2002
Aviation Qualifications: CPL
Posts: 3,392
Likes: 324
From: near an aeroplane
For the Google box to work, the pages you are searching must be visible on the internet and have been indexed by Google. When you set up the box, you can specify to search a specific domain and if that contains the document you mentioned, it should work. Yes, you will get additional 'results', it is Google after all....

Edit: searching a specific page is actually more complex than you would think. The challenge is in defining the range to be searched and storing that temporarily. You can also just put a snippet of text at the top to say 'Hit Ctrl-F to find what you want, or Cmd-F if you're on a Mac'.
There is an explanation of how it works in Javascript here: https://dev.to/am20dipi/how-to-build...avascript-4onf but that uses a pre-defined array of names as the search range.
Jhieminga is offline  
Reply
Old 17th March 2023 | 11:52
  #7 (permalink)  
Thread Starter
25 Anniversary
 
Joined: Jan 1999
Posts: 1,377
Likes: 174
From: England
Thanks Jhieminga. Surprisingly complicated! I use Kompozer for constructing HTML files. It has an edit 'Find . . . ' function which works on both the 'Normal' and 'Source' displays. It's a shame that there is no simple method of incorporating this in the file itself.
Discorde is offline  
Reply
Old 17th March 2023 | 15:05
  #8 (permalink)  
Community Builder
20 Countries Visited
20 Anniversary
 
Joined: Mar 2002
Aviation Qualifications: CPL
Posts: 3,392
Likes: 324
From: near an aeroplane
That is a functionality of the editor you're using. In a similar way every browser has a search function built into it that searches the current page. Both those pieces of software have the text to be searched in their 'memory' at the time, but a page itself doesn't have that. A browser is just a tool that displays, nothing more, if you want more functionality you have to decide whether to use server side processing or use a function built into the website that can be run on the viewer's side. We have a plethora of sites these days that appear to do a lot more than that, but this is heavily dependant on a lot of supporting software on the server side. It's not simple HTML anymore.
Jhieminga is offline  
Reply

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Contact Us - Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service

Copyright © 2026 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.