Solved

invoking ctrl-f

Posted on 2004-03-25
3
4,536 Views
Last Modified: 2012-08-14
I want to open the IE's search window from a link on a HTML page. Is there a way to do this using JavaScript? Sending {CTRL}{F} for exemple.
0
Comment
Question by:Isaac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 6

Expert Comment

by:dgelinas
ID: 10677771
Don't think that's possible but you can do this

http://www.javascript-page.com/pgsearch.html
0
 
LVL 31

Accepted Solution

by:
GwynforWeb earned 250 total points
ID: 10677818
the quick answer to this is basically NO. However here is cross browser code that I use that bascically does the same

<script language="JavaScript">

//Script by GwynforWeb, enjoy and use freely.

// Set browser variables  
var IE4 = (document.all);
var NS4 = (document.layers);

// Set browser window for searching
var win = window;    
var n   = 0;

function FindString(str)
{
 var PageText, Found, i;

 if (str == "")
   return false;
   
 // Sniff for browser
 // Look for match starting at the current point winding around to first match

 if (NS4)
 {
   if (!win.find(str))
     while(win.find(str, false, true))
       n++;
   else
     n++;

   // If not send message.

   if (n == 0)
     alert(" Not Found on Page.");
 }

 if (IE4)
 {
// Set search object to whole page
   PageText = win.document.body.createTextRange();

// Search for nth match from top.
   for (i = 0; i <= n && (Found = PageText.findText(str))  != false; i++)
   {
     PageText.moveEnd("textedit");
     PageText.moveStart("character", 1);
   }

   //  Scroll to and mark text if Found.
   if (Found)
   {
     PageText.moveStart("character", -1);
     PageText.findText(str);
     PageText.scrollIntoView();
     PageText.select();  
     n++;
   }

   // Else, goto top of the page and find first match.

   else
   {
     if (n > 0)
     {
       n = 0;
       FindString(str);
     }

   // Not Found then send message.

     else
       alert("Not Found on Page");
   }
 }

 return false;
}
</script></p>

<form name="Search" onsubmit="return FindString(this.SearchString.value);">
  <p><input onchange="n = 0;" size="17" name="SearchString"> <input type="submit"
  value="Find on Page"> </p>
</form>


0
 

Expert Comment

by:pureandco
ID: 22538069
Thank with a nice script. It work on IE7 but it does not work with firefox 3.0.1. Do you have any suggestion?
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question