0

I'm trying to hide the count value of the Facebook like button when it loads. It runs in an iframe, like this:

<iframe src="//www.facebook.com/plugins/like.php?href='+'facebook.com'+'&amp;send=false&amp;layout=button_count&amp;width=90&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;margin:30px 0px 25px 0px;" allowTransparency="true"> </iframe>

So I tried inserting an onload into the iframe tag, such as:

onload="
function loadme() { 
    // pluginCountTextConnected is the like text count's classname
    var x = document.getElementsByClassName('pluginCountTextConnected');
    console.log(x); 
} 
loadme();
"

But the code returns an empty list. I presume the document reference, in this case, refers to the document that loaded the iframe, not the iframe document. How would I point this to the iframe's content?

Fiddle: here

I should add that the iframe gets loaded from a content-script Chrome extension that runs on Facebook, which is why I was thinking this might not be subject to the same-origin policy.

Update: why did someone vote to close?

mix
  • 6,943
  • 15
  • 61
  • 90
  • possible duplicate of [How can you access an external iframe's contents via the DOM/Javascript?](http://stackoverflow.com/questions/2374697/how-can-you-access-an-external-iframes-contents-via-the-dom-javascript) – rlemon Aug 08 '12 at 22:46
  • possible duplicate of [access iframe content from a chrome's extension content script](http://stackoverflow.com/questions/11325415/access-iframe-content-from-a-chromes-extension-content-script) – Esailija Aug 08 '12 at 22:49
  • You would do this with the same [technique that works on Chrome userscripts](http://stackoverflow.com/a/10669321/331508). (In Chrome, userscripts are extensions -- with some auto-generated options.) You *may* have to set an "all frames" flag, and there are some more options available to you, but the idea is the same. I'll leave you to dig up the details. ;) – Brock Adams Aug 10 '12 at 02:34

1 Answers1

0

the iframe is not hosted on your domain so you have no access to it, look at http://en.wikipedia.org/wiki/Same_origin_policy

ama2
  • 2,611
  • 3
  • 20
  • 28