Following these instructions: https://developers.google.com/+/web/api/javascript
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js?onload=signin';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
Inserted before the tag...
The gapi object that is available inside the signout() callback does not include gapi.client .. in fact, I am getting gapi.client is undefined as a JS error.
I cannot call gapi.client.load('drive', 'v2', callback) since the client property is undefined.
This issue is only when using Firefox Add-on SDK and using cfx run to open a browser with the add-on I am developing being a sidebar element.
Can anyone tell me what I am doing wrong? Can provide more information if necessary!
Related
I'm loading dynamic javascript libraries and I want to do something after they are loaded. Using typescript + angular 8
ie.
const onLoaded = () => console.log('loaded')
const head = document.getElementsByTagName('head')[0];
const script = document.createElement('script');
script.src = 'https://somesite.com/my-lib.js';
script.type="text/javascript";
script.onload = onLoaded;
head.appendChild(script);
The onload Event works as expected in Chrome and Firefox.. and what a surprise, it doesn't in MS Edge.
I tried loading using jQuery*, adding addEventListener('load', onLoaded, false) adding onreadystatechange ... Nothing.
Anybody had similar issues? Anybody know how to fix this?
I need to add support for at least Microsoft Edge 44.18362.449.0 / Microsoft EdgeHTML 18.18363
I am trying to integrate cordova google map in Framework7 html but its not display any map there although I have write similar code for normal html page and its working there. Any help will be highly appreciated.
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//
function onDeviceReady() {
//navigator.geolocation.getCurrentPosition(onSuccess, onError);
var mapDiv = document.getElementById('map_canvas');
var GOOGLE = new plugin.google.maps.LatLng(37.422858, -122.085065);
var map = plugin.google.maps.Map.getMap(mapDiv);
map.addEventListener(plugin.google.maps.event.MAP_READY, function () {
map.setCenter(GOOGLE);
});
}
</script>
You might need to use google.maps.event.addDomListener(window, 'load', initialize);, try to use domlistener within deviceready to load google library asynchronously.
*function loadAsynchronousScript() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp' +'&signed_in=true&callback=initialize';
document.body.appendChild(script);
}*
Try to play around with demo app, this demo app uses Google Maps SDK for cordova: https://github.com/mapsplugin/cordova-plugin-googlemaps
I am trying to add jQuery to my IE 11 extension. When I run it, it gives me the error
SCRIPT5007: Unable to get property _reference of undefined or null reference
on the line
E = jQuery.jstree._reference(o)
I dont understand why though, because the same extension works in Chrome and Firefox? please help. I'd appreciate any help on the matter.
console.log("1");
var jq = document.createElement('script');
jq.src = "https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
console.log("2");
var jq2 = document.createElement('script');
jq2.src = "http://code.jquery.com/jquery-1.11.3.js";
document.getElementsByTagName('head')[0].appendChild(jq2);
console.log("3");
console.log("hi");
appAPI.resources.includeJS('js/angular.min.js');
console.log("passed!");
I am running google custom search in browser it works fine. It runs fine even in emulator in Phonegap but it gives network error or it shows blank screen when the same is run on android phone. or gives this error "file:///google.com/cse?q=.... can not be found."
I am using google custom search v2 code.
The code you get for v2 of custom search looks something like this:
<script>
(function() {
var cx = 'ENGINE_ID';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
What it roughly does is creating a tag like this:
<script type="text/javascript" src="http://www.google.com/cse/cse.js?cx=ENGINE_ID">
and inserts it before other scripts on your page. So you can skip this code altogether and manually insert the above tag (with your engine id) and only <gcse:search></gcse:search> to your HTML. If the connection from file:// to http:// is still not possible, download this script (http://www.google.com/cse/cse.js?cx=ENGINE_ID) and serve it as local javascript file.
I've encountered the same problem. An one-line change in JavaScript made the file:// error go away:
// This line must take place before initializing GCSE
window.IS_GOOGLE_AFS_IFRAME_ = true;
Verified on both iOS and Android Cordova environments.
I've encountered an issue with a custom Google search engine I've integrated into my site. I have some other Google elements on the same page, such as the +1 button and G+ badge, but I've isolated and verified that the search element is, in fact, the culprit.
The problem is the following: the GET request for http://www.google.com/uds/api/ads/3.0/9f53ed6be164615d919d9e4bd4f7fe8d/search.I.js seems to fail (although searching the site still works). The dev console in Chrome says that the request is initiated by their jsapi on line 21 and has the following highlighted in red:
google.(anonymous function).d
(anonymous function)
I've tried multiple test scenarios, including inserting the search box on a completely barebones HTML page, but I get the same error. What is causing the request to fail? Is it simply something on their end (and thus unfixable)?
Edit: Relevant code
This is all taken verbatim from Google's code generators.
This goes right before </head>
<script>
(function() {
var cx = '004344714102800561193:mo5u_njahwy';
var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);
})();
</script>
The search box code:
<gcse:searchbox-only></gcse:searchbox-only>
Search results page code:
<gcse:searchresults-only></gcse:searchresults-only>
Do you have an ad blocker installed like Adblock Plus? I'm getting this error when I run your code in JSFiddle:
Failed to load resource: net::ERR_BLOCKED_BY_CLIENT
It looks like that error is often caused by an ad blocker preventing the file from being loaded: Meta - What are these errors about in the Chrome console when visiting StackOverflow?