Jump to content

Click Link By .innerhtml Linktext..?


cyfer65

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...