-1

I got following script, but it only works in IE, I'd like it to support other browsers as well (Chrome, Firefox), but have no idea how to do it. Script is for search in page Complete script is here: http://goo.gl/aEk3r - Google Docs

function performMultiSearch(elem,searchElem) {
// set up variables
var searchString; // Will hold the text to search for
var theSelection; // Will hold the document's selection object
var textNodes; // Will hold all the text nodes in the document

// Set it to search the entire document if we haven't been given an element to search
if(!searchElem || typeof(searchElem) == 'undefined') searchElem = document.body;

// Get the string to search for
if(elem && elem.value) searchString = elem.value;
else if(this && this.value) searchString = this.value;

// Get all the text nodes in the document
textNodes = findTypeNodes(searchElem,3);

// Get the selection object
if(window.getSelection) theSelection = window.getSelection(); // firefox
else { // some other browser - doesn't support multiple selections at once
    alert("sorry this searching method isn't supported by your browser");
    return;
}

// Empty the selection
theSelection.removeAllRanges(); // We want to empty the selection regardless of whether we're selecting anything

thanks a lot

martinenko
  • 15
  • 1
  • 1
    Why don't you tell us what you want to do -- we can try to infer it by reading the code, but it's more useful if you actually say it. – T.J. Crowder Dec 09 '11 at 08:59
  • 1
    Sorry,but your script is too big.We dont' like to debuging your code.(You can test it in firefox,using firebug console to debug your code) – Oyeme Dec 09 '11 at 09:03
  • Possible duplicate: http://stackoverflow.com/questions/926580/find-text-string-using-jquery – bennedich Dec 09 '11 at 09:17

1 Answers1

0

The script comes from here

http://www.javascriptsource.com/miscellaneous/search-the-page.html

This part of the code does not work in Fx

var reSearch = new RegExp(searchString,'gmi'); // Set it to 'g' - global (finds all instances), 'm' - multiline (searches more than one line), 'i' - case insensitive
       var stringToSearch = textNodes[i].textContent;
       while(reSearch(stringToSearch)) { // While there are occurrences of the searchString

since reSearch is not a function.

If I get the time I can take a look at how to fix it.

mplungjan
  • 169,008
  • 28
  • 173
  • 236