Solved

invoking ctrl-f

Posted on 2004-03-25
3
4,552 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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

615 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