Link to home
Start Free TrialLog in
Avatar of deharvy
deharvy

asked on

Search Page For String Within HREF

I need javascript code that will search all the links on the page and then search for a string value within the href.

Here is an example of the link: <a href="http://www.sample.com/index.jsp?UserIDExample=1111111">

-----------------

Here was my failed attempt:

            if ( document.getElementsByTagName('a').href.indexOf("UserIDExample") > -1 ) {
                        alert("found");
                  else
                        alert("not found);
            }
SOLUTION
Avatar of jordanrynard
jordanrynard

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of deharvy
deharvy

ASKER

Excellent stuff. Thanks!