Browser OnLoad event handler - ajax

I have made an google chrome extension recently. It is working fine except that it works only when user clicks it. I want it to update status even if it is not clicked. So, there is any browser onload action so that I can start updating the status continuously using AJAX.
Thanks :)

Create a background page for your extension.
The background page is loaded as soon as the extension is enabled, so any code in your background page will get executed without needing the user to click anything.

Related

Local storage event listener not working in Firefox

I have a sandbox iframe which is hosted by various websites. Lets assume that this iframe is loaded like this:
'src="https://example.com/wie.js"' I have already added 'allow-scripts allow-forms allow-modals allow-same-origin allow-popups allow-popups-to-escape-sandbox allow-storage-access-by-user-activation' at sandbox. I also use document.requestStorageAccess() from inside the iframe and I set event listeners for the storage like this:
window.addEventListener('storage', onStorageFunc, false);.
From the iframe a popup window is presented when user clicks a specific button and the popup opens at lets say at this url "https://paypal.com". After user navigation on popup, paypal at the end of the flow redirects user to this url "https://example.com/success". At this point when user is navigated to /success I add some data to local storage which I expect to trigger the storage event listener and the onStorageFunc to run.
This doesn't happen, while in other browsers it works as expected.
Since both popup and iframe are under the same url (https://example.com) and I have used requestStorageAccess, I would expect this to work normally. Can you please help me to find out what is going wrong here? In the past I had the same problem but it was fixed when I added 'requestStorageAccess' and 'allow-storage-access-by-user-activation'. Now I can see it happening again.

jQuery maintain fullscreen mode on ajax request with the URL change

I have my project developed in ajax with HTML5 URL history to change / update.
Have any suggestions keepin fullsceen mode also on page change? when loading new pages the browser exits fullscreen mode.
I need to avoid updating the URL and only do when the user exits from fullscreen mode? Do you know what can be the problem? Any advice?

Facebook like button's iframe not expanded after ajax request

I'm adding a facebook share button to each post on a Wordpress (Using Facebook Share Button New plugin), it works ok for each post/page except when i'm loading them trough ajax, the result it's a normal Facebook like button but the popup (to write a comment) appears inside the button it is not expanded.
To check go to: http://iwanttobeher.com/ and then click on any face at the bottom of the page, then test the like button and you'll see what happens.
I don't know what to do, i tried to FB.XFBML.parse() after loading the content but the result is the same.
Switching to HTML5 didn't help in our case. What did was to remove the FB object just prior to new content being inserted into the page via Ajax:
delete FB;
wrapper.html(response.data);
We reload full pages via Ajax and so new page content recreates the FB object and re-initializes XFBML anyway. Not sure if this workaround would work if we reloaded only parts of the page though.
The original answer is here.
I've managed to fix it by changing the implementation to HTML5 instead Iframe or XFBML using Facebook's tool to generate like buttons: https://developers.facebook.com/docs/reference/plugins/like/

EditLive! Rich Text Editor - submitting form via ajax

The project I'm working on is using the Java EditLive! rich text editor. I've been trying to make the EditLive form post via ajax, but am having some problems using IE8. Here are the steps we're taking:
Load the main page
The user clicks a link and the EditLive applet is loaded and attached to the page via ajax
The user finishing editing their document and clicks the submit button
The form posts via ajax (we're using jQuery.post())
The EditLive section is reloaded and the EditLive content is correct.
The form immediately posts again
The EditLive content is back to being blank.
Unfortunately (for debugging reasons), this is not happening in FireFox - there is only a single form post and the values are saved correctly.
From what I can tell debugging this in IE8, it looks like the submit event is getting called twice with 2 different forms. My thought is that the applet isn't getting destroyed correctly, though I've tried everything in my power to destroy it.
So I was wondering if anyone has any experience successfully submitting EditLive data via ajax? Or maybe this is just a limitation to the product?
Any help would be greatly appreciated!
I know this is an old issue but you likely want to look at the autoSubmit property of EL:
http://docs.ephox.com/display/EditLive7/AutoSubmit+Property
http://docs.ephox.com/display/EditLive/AutoSubmit+Property
I suspect that by using an AJAXy submit process this is somehow causing you issues with EditLive and its standard behavior. I would try turning off autoSubmit and grabbing the content yourself in your jQuery posting process.

Google Analytics Event Tracking not working?

I've added the following code to my web app, so that when a user clicks on a button, a google tracking event should be recorded:
//links jquery to button
$(this).click(function() {
//toggles a window on the screen here....
//GOOGLE tracking code
//keep track of what the user clicks on
_gaq.push(['_trackEvent', 'libraryWidget', 'togglesLibrary']); (breakpoint stops here)
});
The problem is, absolutely no events are showing up on my analytics page (page views work fine). I've placed a breakpoint in the code and google chrome does successfully break here. I looked at the console for error messages but nothing shows up. I am using the asynchronous analytics tracker.
Could this be because my analytics code is included at the end of my web page? The jquery code is setup when the page loads, additionally the callback won't be called until the user presses the button.
Can anyone provide some next steps? How can I begin to debug this problem? If I had an error message of some kind I could do something...
I faced this kind of problem too in my localhost, I uploaded to test server which can access from internet, its working.
Another possible thing is Event tracking is not updating dynamically, it will take some times to reflect in your Analytics account

Resources