Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a web page with dynamically generated hyperlinks in a grid view. For every hyperlink should be a corresponding button, which does nothing else than calling the link. How can I reference the href property from my clientclick button event and call it?

share|improve this question
1  
Why bother? I would just style your links, using CSS text-decoration:none; and making sure the :hover and :visited pseudo-class does what you want. This would also be the progressive enhancement solution. –  PHPglue Nov 5 '13 at 22:56

1 Answer 1

up vote 0 down vote accepted

Depending on how you are retrieving the hyperlink, you could just do something like the following:

Html:

<a id="dyn_link_00" href="https://duckduckgo.com/" target="_blank">Duck, duck, GO!!!!</a>

Javascript:

// we assume that the current index is 00 and link is defined in scope.
link = document.getElementById('dyn_link_' + currentIndex);
console.log(link.href.toString()); // yields https://duckduckgo.com/ 
                                   // (toString() might not be necessary)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.