I have an error "Uncaught Chrome Web Store installations can only be initated by a user gesture."
With this code :
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Titre de la page</title>
<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/ajhifddimkapgcifgcodmmfdlknahffk">
<script type="text/javascript">
chrome.webstore.install();
</script>
</head>
<body>
test Chrome
</body>
</html>
I don't understand why as i follow the google tuto : https://developer.chrome.com/webstore/inline_installation.
Someone has an idea?
Thanks.
From the documentation (I have italicized the important part):
Triggering inline installation
To actually begin inline installation, the chrome.webstore.install(url, successCallback, failureCallback) function must be called. This function can only be called in response to a user gesture, for example within a click event handler; an exception will be thrown if it is not.
You cannot just put the install() call in a script tag and have it run automatically.
Related
I have an index.html file and in it I have a script tag that's receiving a callback from google maps. If I remove the timeout, I get this error.
Uncaught TypeError TypeError: window.globalMethod is not a function
My 'globalMethod' is located in a directive being used on the page and I would assume maybe the directive's constructor isn't loaded, but I'm running the google maps script after <app-root></app-root> so you would think it would find window.globalMethod()?
I tried it with 100, but that doesn't seem to be long enough and still receive the error.
Here is index.html
<!doctype html>
<html lang="en">
<head>
// left out other head tags for brevity
<script>
function initPlaces() {
// won't run if I remove window.setTimeout
window.setTimeout(() => {
window.globalMethod();
}, 1000);
}
</script>
</head>
<body>
<app-root></app-root>
<script src="https://maps.googleapis.com/maps/api/js?key=secret-key&libraries=places&callback=initPlaces" type="text/javascript"></script>
</body>
</html>
<html>
<head>
<meta name="google-signin-client_id" content="MY_CLIENT_ID.apps.googleusercontent.com" />
</head>
<body>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script type="text/javascript">
function onSignIn(googleUser) {
console.log("Succesfully Singed in!!!");
}
</script>
</body>
</html>
With the above I can see a google-sign-in button which opens a pop-up accepts credential and signs me in. But I expect onSignIn method to be triggered when the sign in is successful, which is NOT happening.
Does anyone have any pointers at this?
Tried it on apache server on osx with safari, chrome and firefox browsers
You should add your platform.js script in head tag
<html>
<head>
<meta name="google-signin-client_id" content="MY_CLIENT_ID.apps.googleusercontent.com" />
<script src="https://apis.google.com/js/platform.js" async defer> </script>
</head>
<body>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
<script type="text/javascript">
function onSignIn(googleUser) {
console.log("Succesfully Singed in!!!");
}
</script>
</body>
</html>
In my case : The callback function was inside the body tag.
Callback function not work if it is in body tag, move it to head tag.
Check Developers Console and see if Authorized redirect URIs is pointing to the origin you are running the JavaScript?
In my case, the success event wasn't firing because I was trying to hook up a function from an external js file, included on the page. For some reason, the callbacks will only work if the hooked-up functions appear on the very same page.
Never seen anything like this before. I wonder how they check for this.
It's so late to answer but I think somebody will need this:
Remember to add origin URI at google console
If you don't see anything of onSignIn on the terminal, let check at the console of your browser
I am creating phonegap application for android.
I want to check internet connection for application. I am using offline.js.
But it's not working at all for me.
My code is,
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>datePickerAngularTPLS</title>
<link href="css/offline.css" rel="stylesheet" />
<script src="scripts/jquery-1.11.3.min.js"></script>
<script src="scripts/offline.js"></script>
</head>
<body>
<script>
$(function () {
function on(evt) {
alert("connected successfully");
}
function off(evt) {
alert("connection failed");
}
Offline.on("up", on);
Offline.on("off", off);
});
</script>
<!-- Cordova reference, this is added to your app when it's built. -->
<script src="cordova.js"></script>
<script src="scripts/platformOverrides.js"></script>
<script src="scripts/index.js"></script>
</body>
</html>
What is the problem in above code... ?
I just want to show alert on success and lose of internet connection.
I have also tried with navigator.isOnlie, but not reliable.
Please follow offline js LINK
Or other way is :
window.navigator.onLine
This will return true or false.
And one more way is using Phonegap available plugin:
Phonegap Plugin
In your first example you have forgotten to close the $ function. Its likely you would see an error message in the console, and those handlers would never have been created/attached.
If this is just a typo in your question and you are properly closing that function in your real code, then my guess is that you're adding the handlers after the up event has already occurred. Here it explains when these events are triggered.
If you load your page, then toggle your connection on and off do you see the events logged?
I have a simple javascript file like so:
$(document).ready(function () {
alert("my controller");
});
I have an HTML file like so:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript" src="/js/generateLineupController.js"></script>
</body>
</html>
for the love of all things holy why in the world would the alert not show? I get a 200 on GET for the javascript file, so it's loading.
Several problems here.
You're trying to load the script twice for some reason. Don't do that. Load it in <head>, or at the end of <body>, but not both.
You're trying to use jQuery syntax ($(...)), but you haven't loaded the jQuery library. You'll need that.
The $(document).ready(...) indicates that you are trying to use jQuery, but you aren't loading jQuery in your page. Check your console log; you will see the errors there.
Also, there's no need to load the script twice with two <script> tags; just load it once.
I'd like to collect a list of all errors in my webpage (or atleast all errors logged as errors to the console log).
I understand that window.onerror will log my script errors. It also mentions:
"Note that some/many error events do not trigger window.onerror, you have to listen for them specifically. "
I've noticed some errors don't trigger the window.onerror. How would I listen for them "specifically?" (or atleast log the maximum amount of errors possible)
Here is an HTML with a file not found error that won't be caught by window.onerror:
<!doctype html>
<html>
<head>
<script>
var gOldOnError = window.onerror;
window.onerror = function(errorMsg, url, lineNumber) {
alert("Found an error!");
return false;
};
//window.zz.ff.ee.zz; if I uncomment this I get an alert as expected.
</script>
<meta charset='UTF-8' />
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
<title>Simple Example of a file that has an errors</title>
<script src='filethatdoesntexist.html'></script>
</head>
</html>
The best way is using try/catch blocks and use console.error(catched exception) inside catch block to show all errors