troubleshooting Question

Search Page For String Within HREF

Avatar of deharvy
deharvy asked on
JavaScriptHTML
3 Comments2 Solutions338 ViewsLast Modified:
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);
            }
ASKER CERTIFIED SOLUTION
jordanrynard

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros