You can’t. Clicking on the <fb:like>
element has no effect because it’s just a container. The actual clickable “like” button is loaded in an <iframe>
inside of it. Because this iframe is loaded from facebook.com
, the same origin policy prevents you from accessing its contents (including the link you want) unless you are also on facebook.com
.
If this security restriction did not exist, you would be able to use the following jQuery:
$(".fb_ltr").contents().find(".connect_widget_like_button").click()
If this were possible it would represent a massive flaw in the web’s security model. If you find some way to do it, you would find it more profitable to sell the exploit to some criminal organization than to use it generating fraudulent “likes”.
0
solved Trigger a Facebook like button when the page loads [closed]