0

I've got the script to do the autoclick action in X,Y coordinates. It works if the thing behind that particular X,Y coordinate is a button. But if I put a FB "Like" button behind, it just doesn't work. Is there something missing in my code pasted below?

Here's the code:

<html> 
    <body>


<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>


<div class="fb-like" data-href="http://www.facebook.com/realtors" data-width="450" data-show-faces="true" data-send="true"></div>

        <script type="text/javascript">
            function simulateClick(x, y) {
                jQuery(document.elementFromPoint(x, y)).click();
            }
            simulateClick(20, 10);
        </script>
    </body>
</html>
FtDRbwLXw6
  • 27,774
  • 13
  • 70
  • 107
emotheraphy
  • 97
  • 11
  • 3
    You cannot interact with elements inside an iframe from the parent frame for security reasons. (that is, unless some strict rules are met) – Sumurai8 Sep 14 '13 at 15:22
  • Possible duplicate of http://stackoverflow.com/questions/3277369/how-to-simulate-a-click-by-using-x-y-coordinates-in-javascript – Zeke Nierenberg Sep 14 '13 at 15:22
  • If you are doing some testing, I'd recommend to use Selenium http://docs.seleniumhq.org/ – fujy Sep 14 '13 at 15:25
  • @Sumurai8 I've edited the code to remove the iframe. "Like" button will be loaded not via iframe anymore. What could be missing in the code to make it work? – emotheraphy Sep 14 '13 at 15:33
  • Does it 'like' when you click the button yourself? I doubt it will. – Sumurai8 Sep 14 '13 at 15:46

0 Answers0