events of inappbrowser is not fired for windows phone 8 - cordova-2.0.0

I am using cordova 2.4.0. inappbrowser . but events are not being fired in that.
var ref = window.open(url, '_blank');
ref.addEventListener('loadstart', function() { alert("ref"); });
Page get opened in inappbrowser. but event doesnt fire.

Related

How to open A-Frame inspector programmatically when the page loads

I need to open the inspector automatically when the page loads.
You can invoke the openInspector function manually after a-scene loads:
var sceneEl = document.querySelector('a-scene');
sceneEl.addEventListener('loaded', function () {
sceneEl.components.inspector.openInspector();
});
Working example:
https://glitch.com/edit/#!/brawny-candle-shrine?path=index.html%3A17%3A50

Datalayer not getting push on click event?

I m having trouble pushing datalayer to gtm on click event. But datalayer gets properly pushed on a load of the page but not on click. below is my code
$('.load-test-div').on("click", function () {
//console.log('Called properly');
dataLayer.push({
'event': 'display more',
});
});
I have manipulated code in a different way still it's not pushed. For testing, I m using the "Tag Manager" addon of chrome. Is there are any setting to capture click event in google tag manager. Please help!
Without seeing more I can only guess.
For example, this works: https://jsfiddle.net/emo38rbv/
dataLayer = window.dataLayer || [];
document.querySelector('.load-test-div').addEventListener('click', function(){
dataLayer.push({
'event': 'display more',
});
alert('this has pushed to the dataLayer: '+JSON.stringify(dataLayer[dataLayer.length -1]));
});
The issue could be:
Your function is being called before jquery is loaded.
The dataLayer hasn't been declared
The DOM is not ready (the query selector can't find the element)
The element does not exist at the time you run your function

MessengerExtensions.requestCloseBrowser() won't close in desktop

When i try to close the webview with this code:
MessengerExtensions.requestCloseBrowser(function success() {}, function failure(err) {
alert('error closing the window: ' + err); // error closing the window:
console.log(err); // doesn't print
window.close();
});
it closes the webview in iOS, but pops an alert when i try from desktop.
My domain is white-listed, messenger_extensions = true and i enter the page from the desktop messenger and it still doesn't work.
I had before the same problem, but opposite (window closed on desktop, but not on iOS) while trying to use fetch(), and this problem started when started using $.ajax()
before MessengerExtensions.requestCloseBrowser() was invoked from a fetch's promise, and now it's invoked from ajax's success function.
I had to switch fetch with ajax because it didn't work on iOS
Any suggestions?
A day later an error code of 2071011 started to show up, again, only in desktop browsers.
I managed to find a workaround the problem by using window.top.close(); when MessengerExtensions.requestCloseBrowser() fails
It does the same trick on Chrome and asks the user before close on Edge
window.extAsyncInit = function() {
MessengerExtensions.requestCloseBrowser(function success() {
window.close(); // webview closed
}, function error(err) {print ('an error occured');}
);
};
From the documentation on https://developers.facebook.com/docs/messenger-platform/webview/extensions,
window.extAsyncInit() will be called when the Messenger Extensions JS
SDK is done loading. You can use this as a trigger to call other
functions available in the SDK.

Why do Google's JS Client SDK function callbacks fail?

I'm currently in the learning phase for how the Google JS Client SDK works, since my boss needs me to learn how to integrate a Sign In button to his site to enable people to Authenticate via Google. I am testing the code for the custom Sign In button, with a touch of added functionality (like a Sign Out button), and in the process I've practically copy/pasted the code from their website. Let me show you the code first and then explain the issue, so that you can understand where the code is failing:
<script src="https://apis.google.com/js/client.js?onload=init"></script>
<script type="text/javascript">
var clientId = '{my client id here}'; // for web
var apiKey = '{my api key here}';
var scopes = 'profile email';
function SignOut() {
// I know, sloppy, but the signOut method from Google doesn't work.
window.location = 'https://accounts.google.com/logout';
// Additional code if necessary.
};
function makeApiCall() {
gapi.client.load('plus', 'v1', function () {
var request = gapi.client.plus.people.get({ 'userId': 'me' });
request.execute(function (response) {
var heading = document.createElement('h4');
var image = document.createElement('img');
image.src = response.image.url;
heading.appendChild(image);
heading.appendChild(document.createTextNode(response.displayName));
document.getElementById('name').appendChild(heading);
alert('User logged in. makeApiCall() has executed.');
})
})
};
function init() {
gapi.client.setApiKey(this.apiKey);
window.setTimeout(checkAuth, 1);
console.log('Up and ready to go.');
};
function checkAuth() {
// Triggers when the page and the SDK loads.
gapi.auth.authorize({ client_id: clientId, scope: scopes, immediate: true }, handleAuthResult);
};
function handleAuthClick(event) {
// Triggers after a user click event to ensure no popup blockers interfere.
gapi.auth.authorize({ client_id: clientId, scope: scopes, immediate: false }, handleAuthResult);
return false;
};
function handleAuthResult(authResult) {
var authorizeButton = document.getElementById('SignInBtn');
var signoutButton = document.getElementById('SignOutBtn');
if (authResult && !authResult.error) {
var V = JSON.stringify(authResult);
localStorage.setItem('GoogleAuthResult', V);
console.log(V); // Just for testing...
var authTimeout = (authResult.expires_in - 5 * 60) * 1000; setTimeout(checkAuth, authTimeout); // As recommended by a Google employee in a video, so that the token refreshes.
authorizeButton.style.display = 'none'; // Switching between Sign In and Out buttons.
signoutButton.style.display = 'inline-block';
makeApiCall();
} else {
// Immediate:true failed so user is NOT signed in.
// Make the Sign In button the one visible and prep it
// so that it executes the Immediate:false after user click:
authorizeButton.style.visibility = 'inline-block';
authorizeButton.onclick = handleAuthClick;
signoutButton.style.visibility = 'none';
}
};
</script>
The handleAuthClick function does run on the button click, but after taking the user to the Google Sign In page, when that page brings me back, the browser kinda flickers and the handleAuthResult function does not execute. Therefore, nothing changes in the page after the successful sign in; the button displayed is the Sign In button (Sign Out button not visible) and no information is displayed on the 'name' textNode. This happens on Internet Explorer (11), Firefox (39) and Chrome (44). Also, it happens at home on my laptop (straight connection to the web via Cable broadband) and at work (on Windows 8.1 behind an Active Directory).
I began wondering so I started refreshing the browser page and after a couple of refreshes, since the script runs from the beginning, the immediate:true fires again and voilá: user is connected and API call triggers.
So, on my laptop, I changed the function being called back, in the immediate:false line's callback parameter, to the init() function and that fixed the problem: everything runs smoothly from beginning to end. Yet, this is not the way it is supposed to work. I still don't know what is going on with that line.
This morning, on my computer at work (behind Active Directory), that fix didn't work. I have to refresh the page a couple of times so that the script runs from the beginning and the immediate:true triggers recognizing the user's Signed In state and displaying the proper button on screen.
Any ideas on why does this callback fail?
You need to define your apiKey in the first section of your code
var clientId = '{my client id here}'; // for web
var apiKey = '{my api key here}'
Maybe thats the problem.
Google ApiKeys

Google Analytics - Tracking on exit page

i have a from on my page and on submit i will track the submit event. i must on submit goto the other page on a other server. how can i track the submit click before the page change?
Do you have an idea?
You're going to want to use an "event" to track either the mousedown of the submit button and/or a "enter" keypress
// submit button
jQuery('#keyword-submit').bind('mousedown', function (event) {
_gaq.push(['_trackEvent', 'onsite search', search_keyword]);
});
// textbox
jQuery('#searchKeywords').bind('keydown', function (event) {
if (event.keyCode == 13)
_gaq.push(['_trackEvent', 'onsite search', search_keyword]);
});

Resources