Code Snippet

Click Link (based on id) :
<head>
     function clickLink()
    {
          document.getElementById("linkid").click(); 
    }
</head>
<body onload="clickLink()">
   <a id="linkid" href="your url here" />
</body>
Click Link (based on tag name) :
<head>
     function clickLink()
    {
          document.getElementsByTagName("a")[0].click(); 
    }
</head>
<body onload="clickLink()">
   <a href="your url here" />
</body>
Click Random Link (based on tag name) :
<head>
     function clickLink()
    {
          var x=Math.floor((Math.random() * 2));
          document.getElementsByTagName("a")[x].click(); 
    }
</head>
<body onload="clickLink()">
   <a href="your 1st url here" />
   <a href="your 2nd url here" />
   <a href="your 3rd url here" />
</body>
Click Link (based on class name) :
<head>
     function clickLink()
   {
         document.getElementsByClassName("classid")[0].click(); 
    }
</head>
<body onload="clickLink()">
   <a class="classid" href="your url here" />
</body>
Click Random Link (based on class name) :
<head>
     function clickLink()
    {
          var x=Math.floor((Math.random() * 2));
          document.getElementsByClassName("classid")[x].click(); 
    }
</head>
<body onload="clickLink()">
   <a class="classid" href="your 1st url here" />
   <a class="classid" href="your 2nd url here" />
   <a class="classid" href="your 3rd url here" />
</body>
Click Anywhere (based on coordinate) :
<head>
     function clickLink()
    {
          document.elementFromPoint(x, y).click(); 
    }
</head>
<body onload="clickLink()">
</body>

3 comments:

  1. hi are you online rightnow hendryap? want to ask you something :)
    thanks

    ReplyDelete
    Replies
    1. Sorry for late reply,
      just ask me what you need, i'll help you if i can. :)

      Delete
  2. Hello, i will like to know how to repeat the task. Looping it play in xx Times.Again, it will be good if you explain what that code means. Thanks Please add me on skype Umartins22

    ReplyDelete