Jump to content

clicking a href link.


vistar86

Recommended Posts

Hi everyone, hope someone can help my hurdle i'm stumped at...

 

how can i dynamically/programatically click this href link:

 

<div class="rocol1First">
<div class="rolink ">
<a href="/cgi-bin/WebObjects/GSXAppServer.woa/73/wo/0Jb9OjqwmbbcZXnb12HA20/3.45.15.1.3" onclick="javascript: return setSerialNumberInURL(this, 0);"> Coverage Check </a>
</div>
</div>

 

i do not have direct access to change the code manually, and the href location is always different, and to top it all off, the link does not have a name or id :(

 

I'm ripping my hair out, and have spent many days just to get past this! suppose someone will just give me a 5 minute solution and make me look like a complete idiot lol...

 

many, many thanks for even looking and attempting to help me, much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/235806-clicking-a-href-link/
Share on other sites

Try something like this

<script type="text/javascript">
<!--
  function getHref() {
    alert(document.getElementsByClassName('rolink')[0].childNodes[1].href);
  }
//-->
</script>

 

Just call the function getHref when the page loads, or when an element or text is clicked :)

 

Regards, PaulRyan.

Cannot get that working, just realized there is many 'rolink' classes, the only thing that seperates the link is the new code here:

 

<div class="rocol1First">
<div class="rolink">
	<a href="/cgi-bin/WebObjects/GSXAppServer.woa/73/wo/0Jb9OjqwmbbcZXnb12HA20/3.45.15.1.3" onclick="javascript: return setSerialNumberInURL(this, 0);">Coverage Check</a>
</div>
</div>

 

the rocol1First would be the one to go for if clicking by class value as this is the unique key.

 

if i'm not able to click the href then even getting the location from it into a variable would do.

 

thanks for your help though.

 

In future you will have to try abit harder, I gave you the basis to get the href value in my first post.

Luckily for you I'm in a good mood this morning :)

 

<script type="text/javascript">
<!--
  function getHref() {
    var tehHref = document.getElementsByClassName('rocol1First')[0].childNodes[1].childNodes[1].href;
    alert(tehHref);
  }
//-->
</script>

 

Use the above code, it will work now.

 

Regards, PaulRyan.

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.