I have tried adding a Deezer share button in my InApp by adding the dz-share class and the two data attributes like described in the demo InApp instructions:
<a class="dz-share" data-id="302127" data-type="album"></a>
However, nothing happens when I click my share link. I don't even see the click event listeners or the dz-btn dz-parsed dz-inapp dz-widget classes on my link like I see in the demo application. I suspect this is because my app page gets loaded dynamically, i.e. the button element is not initially there.
Is there any way to trigger the Deezer share dialog programmatically with javascript?
You can try DZ.framework.parse().
See the docs here.
Note that you will need your app to be in Deezer to make it work (meaning in the Deezer iframe)
Related
I am trying to profile some javascript code on this url by setting an event listener breakpoint on mouse click.
When you click on any flight on the results page, it opens a new tab with another link and the logic to build that link must be using javascript, since there is no network traffic going on when the click is done.
The problem is when doing a profiling it shows some js functions called but none of them related to the new tab opened. Maybe it is related to some other event? Any other ways to profile this use case?
Basically the goal would be to understand how that new tab link is generated and get it without the need to actually click it, using data that must be already present somewhere on the code beforehand.
Any insights would be appreciated!
I'm building a page that is aggregating other pages in a Wordpress site, and displaying snippets of information about them along with a 'Like' button. Right now I'm using the iFrame option.
What happens is when a user clicks on a video, it displays it in a Feature area with the video, some text, and a Like button. This HTML is generated from a template and created after a user clicks on a video to watch it. There isn't a page refresh.
If I use the HTML5 version of the Like button, it never gets rendered, which I'm guessing is because the Like div never exists when the Facebook init is called. I'd like to not use the iFrame version though, because it doesn't seem to let me allow people to comment on their like.
Is there a way to have Facebook re-scan for elements to render? I know that Twitter will allow you to do this by running twttr.widgets.load() at any time to have it rescan for things to render.
Just call this function after loading the dynamic site, i am pretty sure it´s what you need:
https://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse/
I need to get the status of a twitter "follow" button on load, not on click.
I'm currently loading the button via ajax, and call twttr.widgets.load() to get the widjet.js to do it's magic.
I am aware of binding "follow" and "unfollow" to accept the callbacks from clicking the buttons, but how do I detect the current state of the button before any user interaction?
For instance, the page loads and the user is signed into twitter and currently following the target of the follow button, so it appears that they've already followed the user.
How do I detect this with javascript/jquery? I am not authorizing them through twitter at this point, so I can't check via their api.
Other attempts:
I've also tried getting the contents of the iframe via javascript,
since the twitter follow button iframe has a class specifying the
state of the button, but it doesn't seem to be possible due to CORS.
I expect the answer is you can't.
The twitter follow button is in an iframe expressly to prevent you from accessing it and obtaining information they don't want you to have.
Facebook operates similarly. The like button is in an iframe, and therefore you cannot use it to determine if a person has 'liked' a particular page. That information requires permission from the user.
On a website, I have some social buttons (tweet, facebook like, google+1, ..). Most of them are inserted using an iframe.
The task is to track use interaction with those buttons: if someone +1'ed the content - and AJAX request should update my local statistics on the server.
However, with JS I can't access the contents of the iframe due to security restrictions: can't bind 'click' event.
How do I track clicks on those social buttons, then?
Possible solutions:
Bind 'click' to the iframe object itself: it does not work.
Add buttons inline, w/o an iframe. No go: I should also display the number of likes for every button.
Try to use Social Service APIs to insert without an iframe. Not all services support this.
You can't. If you could catch clicks on them you could also trigger clicks on them which would be pretty bad (imagine porn sites making you "like" them automatically).
The only thing you can do is using the APIs of the various sites to retrieve the number of people who liked/+1'd/etc. your site.
Most of the social buttons from the main companies enable your Javascript to detect when the button has been pressed. They usually do this via Javascript events.
In other words, they'll tell your code that they've been pressed, you don't have to detect it on your own.
Twitter
info on their javascript events
Facebook
You need to use the XFBML version of the button. From the Facebook Like button FAQ
How do I know when a user clicks a Like button?
If you are using the XFBML version of the button, you can subscribe to the 'edge.create' event through FB.Event.subscribe.
Google +1
See the callback parameter in their docs. See section +1 Tag Attributes. You provide a Javascript (JS) function to their button. Your JS is then called by them when the button is pushed. Easy!
I have a Google Chrome extension that opens a Twitter Bootstrap dialog (using JQuery 1.7.x, but not JQueryUI) from a context menu item click, and I've been trying to do the same thing in the Firefox version (using Add-on SDK 1.6), to no avail.
I can intercept the menu item clicks OK in my lib/main.js, using context-menu, but I can't get a message to the content script (see https://stackoverflow.com/a/8493844/954442) which contains the function that creates the dialog DOM and that displays it. Nor can I create the dialog from my add-on script because there's no DOM there (and attempting to load JQuery into that via #mozilla.org/moz/jssubscript-loader;1 fails with "window is not defined")
I've looked far and wide for examples, but haven't found much that helps. Has anyone got an example of a context-menu Item click opening a dialog?
(What are the advantages/disadvantages of using the Add-on SDK to develop my Firefox extension? is the nearest thing I've found to my issue. I get the impression the poster found an answer eventually, but didn't update the question to say what it was.)
(NB. I'm not prepared to consider XUL, and very reluctant to go back to JQueryUI)
Ok, so I believe you want to do something like that:
https://builder.addons.mozilla.org/addon/1049738/latest/
Basically you add a contentScriptFile property to your context-menu's Item. A content script doesn't share the js variable with the page, however can access to the DOM. So you can add your panel and display it when the context-menu item is clicked.
Notice that you can pass to contentScriptFile multiple files using an Array, so you can load jQuery as well in this way.
Hope it helps.