views:

141

answers:

3

I'm developing a script for Greasemonkey, but I'm stuck trying to activate links via JavaScript.
The script should check the web page for a certain href link and, after finding it, it must activate it (like clicking on the link).

If it helps, the href I'd like to activate is a "javascript:FUNCTION" kind of link.

+4  A: 

Find the url that you want to direct the user to and then use

var href = ...//find url
window.location=href;
Yacoby
+1  A: 
<html>
<body>
    <script language="Javascript" type="text/javascript">
     function somescript() {
      window.location.href = document.getElementById('ololo').href;
     }
    </script>

    <a href="javascript:alert('test');" id="ololo">test</a>
    <br />

    <a href="javascript:somescript()">click me</a>

</body>
</html>
silent
A: 

For functionalities like these where an onclick has to be fired on elements, I find it easy and fast to use jquery. If you can include jquery, then you can use the click() function on that element.

vsr