-1

i am currently making a static webpage this page will have a lot of text and i want the users to have the ability of searching exactly as they would do with the find feature of a browser(ctrl+f) i found a couple of javascript files that could open a window and search but it's not what i am looking for, i want something that will search and highlight as fast and easy as browsers do so because i can't find something like this, i want to put just a button that by being clicked it will enable the find feature just as it would by pressing ctrl+f it's hard i know but help me please

edit: i had find these too but you have to click to search

http://javascript.about.com/library/blufind.htm?

http://www.seabreezecomputers.com/tips/find.htm

firstroad
  • 57
  • 1
  • 1
  • 9
  • You haven't attempted anything yourself, you should program it first, if you hit a wall, come back here and we will help you. – Mr. Alien Jun 17 '13 at 05:05
  • Why can't you let the browser's Ctrl+F find-text functionality do the hard work for you? It's built for static text, after all. – michaelb958--GoFundMonica Jun 17 '13 at 05:16
  • @Mr.Alien i imagine that this needs javascript or even worse jquery but i don't have the ability to "program it myself" but i swear i searched how to do it in javascript – firstroad Jun 17 '13 at 05:31
  • @michaelb958 this is my last option, but because my webspage aims to older audience i prefer to have a button, also a recent research shoed that only 10% of web users know about ctrl+f – firstroad Jun 17 '13 at 05:33
  • @firstroad Why not a bit of text saying `Press Control+F to search for text`? – michaelb958--GoFundMonica Jun 17 '13 at 05:56
  • @michaelb958 cauze i told you i aim to an older audience http://www.lolntroll.com/how-to-press-f5-key/ – firstroad Jun 17 '13 at 06:06

1 Answers1

0

As other users have already pointed out, what you are trying to acheive will not work - at least not as expected and definitely not cross browser. It's also good to search before posting here. I found several links, however ultimately settled on a year old post on this website.

Ultimately, you cannot sendkeys at this level so either you need to create something similar to some of the links suggested by other users in the linked thread, or as @michaelb958 suggested, have the user manually hit Ctrl+F.

Use Browser Search (Ctrl+F) through a button in website?

Community
  • 1
  • 1
redditor
  • 4,196
  • 1
  • 19
  • 40
  • well i had already see this post on the link of the first answer but apart from not being cross-platform, it doesn't highlight the text while you search... – firstroad Jun 17 '13 at 05:44
  • @firstroad I'm afraid this functionality doesn't exist in JS or HTML - having said that it may be theoretically possible to make something from scratch using jqeury and something like PHP but I really wouldn't recommend going down that almost endless path. With something like this link: http://www.javascripter.net/faq/searchin.htm it might be possible to add additional functions that temporarily change the CSS on found words but this would be something you would need to work on and then perhaps ask a new question once you hid a wall with it. – redditor Jun 17 '13 at 05:49
  • nice link, is there any way to make it work with the .keypress event of jquery so when you type in your keyboard, this searches? – firstroad Jun 17 '13 at 06:02