0

So, I've been tasked with maintaining a legacy application and trying to make it cross browser. I've stumbled across posts like this (Javascript: access DOM elements without getElementById) which articulate the issue that I have.

Namely, in IE, you can work with an element in the DOM by just calling it by its ID. It's non-standard but it works. Obviously, the second you go to Chrome or Firefox, none of the old code works anymore, as Chrome or FF depends on you using something like getElementByID (which is the correct, standards based way).

This application also uses things like document.all to find if certain controls are there, and if they are, to work with them. This all happens without getElementByID.

So, is there an easy way to find this kind of IE dependent code so I can strip it out and replace it with something more modern? Or not really?

Thanks!

EDIT:

So, this is some of the code that is in the existing JS

for (var i = 0; i < grdPreviousEpisode.rows.length; i++)
... 
}

Now, grdPreviousEpisode is a GridView (in Web Forms). This is manifested as a HTML table. This code isn't using a "getElementById" function to go and pull this out of the DOM "the right way". Its relying on IE's terribad way of passing items through out of the DOM when there isn't a visible JS variable.

There may be other areas in this code which specifically rely on IE dependent hacks, and I would like to not have to manually find/replace those things. Does that make sense?

Community
  • 1
  • 1
Lewis Cianci
  • 926
  • 1
  • 13
  • 38

1 Answers1

0

If I understand correctly, you want to do a search and replace to all file in a project folder. There is a few ways I can think of

  1. Import the project into an IDE such as netbeans: Search and Replace Entire Project (Netbeans)
  2. Use Note++. Press control+f -> Find in files. Enter "*.js" in the filter
  3. Use grep in if you are in a Linux environment
Community
  • 1
  • 1
Anthony Poon
  • 837
  • 6
  • 14
  • So, kind of, but not really. I want to find *implementations* which are no longer compatible. I'll update my question with an example of what exactly I want to do. – Lewis Cianci May 17 '17 at 03:36