1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How To Simulate/Force Click A Link.

Discussion in 'Black Hat SEO' started by MarketerX, Aug 14, 2011.

  1. MarketerX

    MarketerX Regular Member

    Joined:
    Mar 7, 2010
    Messages:
    398
    Likes Received:
    120
    Was just reading seo20's script thread from awhile back, and found out part of the simulate click script doesn't work. I found a solution so thought I would post it.

    Here is the original script.

    Code:
    [COLOR=#000080]<html>[/COLOR] 
    [COLOR=#000080]<body>[/COLOR]
    [COLOR=#800000]<script type=[COLOR=#0000FF]"text/javascript"[/COLOR]>[/COLOR]
    function simulateClick(control)
    {
        if (document.all)
        {
            control.click();
        }
        else
        {
            var evObj = document.createEvent('MouseEvents');
            evObj.initMouseEvent('click', true, true, window, 1, 12, 345, 7, 220, false, false, true, false, 0, null );
            control.dispatchEvent(evObj);
        }
    }
    [COLOR=#800000]</script>[/COLOR]
    
    [COLOR=#008000]<a href=[COLOR=#0000FF]"http://www.blackhatworld.com"[/COLOR] id=[COLOR=#0000FF]"mytest1"[/COLOR]>[/COLOR]test 1[COLOR=#008000]</a>[/COLOR][COLOR=#000080]<br>[/COLOR]
    [COLOR=#000080]<div id=[COLOR=#0000FF]"mytest2"[/COLOR] onclick=[COLOR=#0000FF]"alert('Here we go');"[/COLOR]>[/COLOR]And in a Div[COLOR=#000080]</div>[/COLOR]
    
    [COLOR=#800000]<script type=[COLOR=#0000FF]"text/javascript"[/COLOR]>[/COLOR]
        simulateClick(document.getElementById('mytest1'));
        simulateClick(document.getElementById('mytest2'));
    [COLOR=#800000]</script>[/COLOR]
    
    [COLOR=#000080]</body>[/COLOR]
    [COLOR=#000080]</html>[/COLOR]
    The problem is that the simulated click doesn't work on the "mytest1" link. However, there still is a way to make it work. Test the one above then test this one, and edit accordingly. The difference is, instead of force clicking a link, which firefox and various popup blockers don't allow, they are actually clicking 5px5px invisible div which redirects the page when the OnClick event is fired...so the desired effect is achieved...

    Code:
    <html> 
    <head>
    <script type="text/javascript">
    function replaceDoc()
      {
      window.location.replace("http://www.blackhatworld.com")
      }
    </script>
    </head>
    <body>
    <script type="text/javascript">
    function simulateClick(control)
    {
        if (document.all)
        {
            control.click();
        }
        else
        {
            var evObj = document.createEvent('MouseEvents');
            evObj.initMouseEvent('click', true, true, window, 1, 12, 345, 7, 220, false, false, true, false, 0, null );
            control.dispatchEvent(evObj);
        }
    }
    </script>
    
    <div id="link" onclick="replaceDoc();" style="height:5px;width:5px;opacity:0.1;filter:alpha(opacity=10)"> </div>
    <script type="text/javascript">
        simulateClick(document.getElementById('link'));
    </script>
    
    </body>
    </html>
    Hope this helps some of you that wanted to get this feature of seo20's script to work.
     
    • Thanks Thanks x 1
  2. GreyWolf

    GreyWolf Executive VIP Jr. VIP

    Joined:
    Aug 17, 2009
    Messages:
    1,930
    Likes Received:
    5,389
    Gender:
    Male
    Occupation:
    Artist / Craftsman
    Location:
    sitting at my PC
    Since it addresses a potential problem with SEO20's script it probably would have been better to have posted in his thread to so other people reading it could see your solution there. If you're starting a new thread for it instead though you might have referenced the specific thread. Here's the original thread for anyone that wants to read other replies to SEO20's script.
    SEO20's ultimate script-collection FREE

    Cool workaround you came up with though for compatability with more browsers. Good job. :cool:
     
  3. meannn

    meannn Supreme Member

    Joined:
    Apr 22, 2009
    Messages:
    1,461
    Likes Received:
    1,896
    Occupation:
    Unemployed Winner
    Location:
    TR
    ^^ Most of them are not working. They need some freelancer/elance hires. lol.
     
    Last edited: Aug 14, 2011
  4. VIC SEO

    VIC SEO Elite Member

    Joined:
    Feb 19, 2010
    Messages:
    2,156
    Likes Received:
    363
    Gender:
    Male
    Occupation:
    SEO Specialist
    Location:
    iSynergyMedia
    Home Page:
    Thanks for posting this one, it really did help me when I was stuck with something and I had no clue on how to tackle the problem.