Jump to content

Click Link By .innerhtml Linktext..?


cyfer65
 Share

Recommended Posts

You'll have to loop through all links and check the innerHTML one by one:

links = document.getElementsByTagName("a");for (var i = 0; i < links.length; i++) {	if (links[i].innerHTML == "LinkTex") {		window.location = links[i].getAttribute("href");		break;	}}

Note that setting the location to the link's href is not the same as clicking on it, e.g. the onclick handler isn't fired.

Link to comment
Share on other sites

is there anyway to make onclick handler get fired..??
It's not simple, but there's a procedure that uses dispatchEvent().http://www.howtocreate.co.uk/tutorials/javascript/domeventsThis is advanced Javascript, you should have a good knowledge of events and event handlers before trying this.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...