vistar86 Posted May 8, 2011 Share Posted May 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/235806-clicking-a-href-link/ Share on other sites More sharing options...
PaulRyan Posted May 8, 2011 Share Posted May 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/235806-clicking-a-href-link/#findComment-1212132 Share on other sites More sharing options...
vistar86 Posted May 8, 2011 Author Share Posted May 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/235806-clicking-a-href-link/#findComment-1212246 Share on other sites More sharing options...
vistar86 Posted May 8, 2011 Author Share Posted May 8, 2011 anyone else have a clue? Quote Link to comment https://forums.phpfreaks.com/topic/235806-clicking-a-href-link/#findComment-1212250 Share on other sites More sharing options...
PaulRyan Posted May 8, 2011 Share Posted May 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/235806-clicking-a-href-link/#findComment-1212288 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.