Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.