Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

HTML <a> href that points to another <a> href

I have a hidden <a> tag with some id. It renders by script, so I don’t have access to it. And I have my own <a> which is visible to user. I want to when user clicks my own <a> it redirects him with same href which script rendered <a> have.

I can’t use <script> tag or js script files.

<a href="/somegerantedhred" id="someId" style="display: none"></a>

<a href="somehow get same href"></a>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you can add some javascript into your element instead of the script, you may have some luck using onclick. Then target the hidden link, get it’s href value, and use it to change the window location:

<a href="/somegerantedhred" id="someId" style="display: none"></a>

<a onclick="window.location.href = document.getElementById('someId').getAttribute('href')">Your button</a>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading