Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

making a button to start the Search function (CTRL+F) 1

Status
Not open for further replies.

math

Programmer
Mar 21, 2001
56
0
0
BE
I want to make a button so people can search the current page using the already implemented function. You can open it by doing CTRL+F in almost any browser !! but I want a button that does that on my page? I think its the same as for making a button to add the current site to your Favourites, but I don't know how! Can Anyone Help?

Thanx in advance!!
math
 
I know there is a window.find() method, but I can't seem to get it to work :-(

Maybe someone else will help.

Greg.
 
Hi math,

I have been trying to get something useful for your question,and I got this script.It only works for IE.
It's a form field with a search button.It looks for all the text in between <body> and </body>.

Maybe it could be useful for you.I hope this helps.

<html>
<head>
<script>
function findText(textString)
{
if(textString!='')
{
var range = document.body.createTextRange();
var found = range.findText(textString);
if(found) { range.select(); range.scrollIntoView();}
else alert('Sorry, no matches found');
}
else
alert('Sorry, no matches found');
}
</script>
</head>
<body>
<form>
Enter Search Term 
<input type=&quot;text&quot; id=&quot;search&quot;>
<input type=&quot;button&quot; onclick=&quot;findText(search.value);&quot; value=&quot;GO!&quot;>
</form>
<br><br>
Good morning<br>
Goodbye my dear friend<br>
Hello Everyone<br>
</body>
</html>

It's based on a script developed by Peter Bromberg.
window.find() is not available any longer since JS 3.0.

I'm trying to help.

Kindest Regards

alexfusion
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top