Forum Moderators: open
I am trying to write a bookmarklet for some tasks in a cms that is using javascript heavily.
In order to create one of the desired functions I need to programmatically click on a link.
<a href="blabla" id="mylink">mylink</a>
---> document.getElementById('mylink').click();
doesnt work. Obviously the link object does not support this function.
I can not change the link to a button or similar. Also I cant just change the document.location because the link activates some further javascript functionality. Does anyone have an idea to be able to activate that link?
With best regards
Waldemar
thanks, but it didnt do the trick. I tried:
<BODY onload="test();">
<a href="http://www.webmasterworld.com" id="mylink">Link</a><script type="text/javascript">
function test()
{
alert("function called");
eval ( document.getElementById('mylink').href );
}
</script>
</BODY>
and get this error:
Error: syntax error
Line: 18, Column: 29
Source Code:
[webmasterworld.com...]
--> error kind of makes sense to me, as I am trying to execute an URL with this... ;)