javascript - Like button not working in a Chrome extension -
i have implemented simple facebook "like" button in extension. however, not appear working.
i using iframe
version of "like" button because won't need scripts.
<iframe src="//www.facebook.com/plugins/like.php?href=[dummy_text]&send=false&layout=button_count&width=100&show_faces=false&font&blah..." scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowtransparency="true"></iframe>
at first, button show nicely , correctly:
however, after clicked it, "error" in red:
so thinking maybe because of (kind of stupid and) restricted policies added in manifest version 2?; since works if put on regular webpage. (it says "confirm" after click button.)
any idea on how fix this?
//www.facebook.com/...
protocol-relative url. when embed such url on normal http(s) site, url resolves http(s)://www.facebook.com/...
. however, in chrome extension, resolves chrome-extension://www.facebook.com/...
...
to fix issue, prefix url https:
, i.e. use https://www.facebook.com/...
.
after doing that, button still not show because of content security policy. desired result, have allow facebook embedded, relaxing csp via manifest file:
"content_security_policy": "script-src 'self'; object-src 'self'; frame-src https://www.facebook.com",
(you can whitelist http sites, e.g. using
"script-src 'self'; object-src 'self'; frame-src http://www.facebook.com"
or
"script-src 'self'; object-src 'self'; frame-src http://www.facebook.com https://www.facebook.com"
)
Comments
Post a Comment