When a user clicks the twitter share button a web intent window is brought up on an already greyed out background (using an overlay). I am curious if there is a callback from the twitter web intent window to know when the window is closed or a tweet is submitted so that I can fade out the greyed out window once the user is done with the twitter intent window. Any help would be appreciated.
You can do something like this.
twttr.ready(function (twttr) {
twttr.events.bind('tweet', function (event) {
//do something
});
});
Using FirstDivision's answer, you can detect a successful tweet, but you will miss the case where the user closes the window without submitting a tweet.
According to this discussion thread, there is no official support for a failure event:
https://dev.twitter.com/discussions/17386
I am not sure if there is an acceptable work-around.
Related
I'm tiring to login with google on popup window, that of course I'm opening in my code with window.open(). The problem is that I couldn't listen load envent on the new window because, the popup belong to other domain (google) and the event is Blocked by JavaScript.
I need to know when the popup is opened and when de user is logged in (url changes, and navigate to my own callback page).
Please can someone help me!!!
Thanks very much.
There is no way to do that with a site that does not cooperate.
If you are trying to use Google as a login service for your site, you can look at OAUTH.
The way it works is, in short:
Call Google
Give them a web page to call if the login works.
hello i have a Django base app and one of its apps is chatting with customer service.
i want when the customer clicks on the the [x] icon or close the window, a small popup window should come up that include:
1.a string like "thank you, and we hope you can take time and answer the survey:"
2. a button that directs the customer to the survey page.
i have this part of the chatting app java script file:
window.onbeforeunload = function() {
window.open ("http://gadgetron.store/male_chatbot/popup/"); <= i have tried it and it doesn't work
$.ajax({
type: 'GET',
url: 'http://gadgetron.store/chatbot/run_python_clear_chatM/',});}
thank you,
I tried some thing like that before, but I think the browser disabled the popup customization. and note that you need configure the ajax call as synchronous (check this). you can use window.onunload event handler, and then small popup with confirm and cancel button, if you click on confirm you script will be executed and the tab will closed
For user experience reasons, browsers do not allow opening Popups during the unload-phase, which this event is part of. The only thing you can do is open a popup, asking the user to confirm that he really wants to leave the page. This is achieved by returning any non-empty string from the event callback (ie. return "Are you sure you want to leave?"; where you currently call window.open). The text inside this confirmation window can no longer be influenced by the application for most modern browsers.
For information regarding popups during the unload phase, have a look at the WHATWG Spec, most importantly the ignore-opens-during-unload counter which blocks document.open when set to any value greater than 0.
I'm developing a google chrome extension that will insert a button in facebook profile cover, using content script that documented in chrome API i can insert that button on the refresh the page or open the profile in other window - tab, the problem is open any profile link in the same window - tab will not add that button! I think facebook load the content via AJAX without refresh the page.
I used that code:
$("div#contentArea").on("DOMNodeInserted DOMSubtreeModified DOMNodeRemoved",function() {
// Do somthing
});
but it does not fire on navigate between profiles!
How to know if the user is open other profile? I'm thinking to check url for every 1 seconds but is that the final solution?
I know it's been long time for this question, but I see it will be better to share the solution, a new one!
It's not good to use any of these DOMNodeInserted DOMSubtreeModified DOMNodeRemoved, instead use this API from HTML5 MutationObserver.
There is more than that you can use within MutationObserver is this library mutation-summary.
Thanks for Firefox developers because they share this with me when I submitted this add-on to store.
Best if luck to all.
I am trying to use the FB.ui oauth popup on a Facebook Canvas Page. I am using the latest Javascript SDK.
On a Page Tab, it works great to just do: FB.ui({method: 'oauth'}, callback); That gives me the allow access popup and then calls my callback with the response perfectly. No redirect is necessary.
However when I try the exact same thing on a Canvas, I get a FB dialog that says "An error occurred. Please try again later". Has anyone gotten it to work, or know of any workarounds?
I did have success with the top.location.href = "http://www.facebook.com/dialog/oauth?client_id=xxx&redirect_uri=xxx approach, but I would prefer to not have to redirect if possible.
It turns out that FB.login(callback) works fine on a canvas page, and it avoids the redirect as well.
So the answer for me was to just change the FB.ui to instead do FB.login. The response sent to the callback is slightly different from FB.ui, but very close.
FB.login(function(response) {
if(response && response.session) {
//do stuff with session
}
});
What does "it does not work" mean? The popup might be blocked if it's not called in reaction to a user event (like a a mouse click).
Facebook Connect has a recent bug that is causing the permissions pop-up window to not close and refresh the parent window as it is designed to do. Instead, after approval by the user it attempts to load the page directly in the pop-up window which is an awful user experience and really hurting our registrations. You can see the bug by registering for our site using Facebook Connect: http://alltrails.com
The URL of the page after the user connects that Facebook Connect is incorrectly loading in the permissions pop-up window is of the form:
http://alltrails.com/?installed=1&session={"session_key":"2.Gu0duOqdElNjXRac5wnetw__.3600.1283799600-1486832834","uid":1486832834,"expires":1283799600,"secret":"tKFaEgBTF9RJeuQZfYUSCw__","base_domain":"alltrails.com","sig":"a8dd9f75418b530ae6c3d935e14274c4"}
I'm hoping that someone much better at JavaScript than myself could suggest a simple code snippet that we could add to our homepage that would only be invoked if the page URL includes '?installed=1' and would do the following to allow the same user experience as Facebook Connect was intended to provide:
Close the permissions pop-up window
Load the appropriate page http://alltrails.com/register/facebook in the original parent window
I've tried to do this a bunch of different ways but haven't had any luck with getting it to work correctly. Thanks in advance for your help!
It's a (unconfirmed) bug.
http://bugs.developers.facebook.net/show_bug.cgi?id=12260
Hopefully it gets more votes so it gets fixed - vote people!
In the meantime, i am (attempting) to employ the following 'creative workaround':
Add logic to my Default.aspx page to detect that URL they are redirecting to in the popup.
Redirect to my page, FacebookInboundAuthorization.aspx, preserving querystring.
On load of that page, register some JavaScript to close the popup and manually fire the "onlogin" event handler for my button.
EDIT - Another possible solution
So i do something like this for the "Disconnect from Facebook" button, which has a similar bug which has been in FBC from day 1. If the user is already logged in, and you click the "Disconnect from Facebook" button, the "onlogin" handler is not fired.
So what i ended up doing is replacing the Facebook Disconnect button with my own regular anchor tag, mimicing the Facebook CSS. This way i can have full control over the click event (fire the function i want).
So, this principle could (theoretically) be applied to this current bug.
That is, after you do FB.Init on client-side:
Check FB auth status using FB.Connect.ifUserConnected
If user is connected, hide the regular FB:Login button, and show your "fake" FB Login button. Copy across the "onlogin" function from your regular FB:Login button to your fake button as the onclick event.
Your Fake FB Login button would be a regular anchor tag, with the same CSS applied to the regular FB Login buton.
So essentially, if the user is already connected, we don't really need FB's intervention for authentication, we can just do whatever we want (request perms, redirect, etc).
That should work.
Unfortunately i have higher priority things i need to work on, but it sounds like this is top priority for you.
So give that a go, hope it helps.