jQuery bug in IE 11 - javascript

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!");

Related

Microsft Edge wont execute script.onload

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

Chrome: Cannot read property 'getAll' of undefined

I'm new to Javascipt and just trying out some examples I found in the net. This one doesn't work at all. I open about:blank in Chrome and use a Console there. When I run this code there's an error Cannot read property 'getAll' of undefined'.
chrome.windows.getAll({populate:true}, getAllOpenWindows);
function getAllOpenWindows(winData) {
var tabs = [];
for (var i in winData) {
if (winData[i].focused === true) {
var winTabs = winData[i].tabs;
var totTabs = winTabs.length;
for (var j=0; j<totTabs;j++) {
tabs.push(winTabs[j].url);
}
}
}
console.log(tabs);
}
Also it seems like chrome doesn't have property windows in it...
That seems like it is using the Chrome Extensions API. You can't just run it in the console. You can get started with Chrome extension development here.

why dont i get "NetworkError" in javascript when i use <script src="false_ip">?

this is my simple script,
<script>
window.onerror = err;
var script = document.createElement('script');
script.src = "192.186.1.1.1.1.1";
script.onerror = err;
document.body.appendChild(script);
function err(msg, loc, a, b) {
alert(msg + "/" + loc);
}
</script>
but when i load this i get,
[object Event]/undefined
when i run the same on "firebug" i get detailed error like,
NetworkError: 404 Not Found - http://localhost/XSS/192.186.1.1.1.1.1"
So how can i get a detailed error .
try-catch alos doesnt work
try {
var script = document.createElement('script');
script.src = "192.186.1.1.1";
document.body.appendChild(script);
} catch(e) {
alert(e.name);
}
does that method will work only in old browsers ?
img.src also doesnt provide fire error handler. why?
var img = new Image();
img.src="gifffff/asasa/ss" ;
Firebug is not code, but a browser diagnostic tool running on the agent's behalf. (JavaScript cannot read the result of the firebug console.)
Now, for the cases:
The Image.error event never says why the loading failed. There is no provision to include the "reason" in the HTML specification; problem solved by not being a feature to begin with.
The catch doesn't work because there was no Exception thrown by the code.
The Image is still an Image and can still be added to the DOM
regardless of if the resource (eventually) fails to load.
(The src is still set to a valid URI component - it would have thrown an exception on an invalid/unknown URI scheme.)
Having this general limitation (on any [Image] resource, even on the same origin) also prevents violation of the Same-Origin Policy - and the ability for malicious code to run various network scanning attacks.

gapi.client is undefined -- firefox add-on sdk

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!

Javascript Console.log Not working in Chrome, or Firefox

I am doing a very simple:
console.log("Testing");
along with :
alert("testing");
The Alert works (so I know the javascript is working) but I'm unable to see the log. When I use Firefox I get the following error:
The Web Console logging API (console.log, console.info,
console.warn, console.error) has been disabled by a script on this
page.
What is going on? I have looked at the following topics, but none have helped:
Chrome: console.log, console.debug are not working
console.log quit working in Chrome
Console.log not working in Chrome [closed]
why does console.log not output in chrome?
Console.log not working at all
I have also made sure that the funnel is working and that logging is turned on.
What else could the problem be?
I just came across this problem after a Firefox update and managed to fix it. Here's the code that caused the problem:
/* IE fix that allows me to still log elsewhere */
if (typeof(console)=="undefined") {
var console = {
output: null,
log: function (str) {
// we can't emulate the console in IE, but we can cache what's output
// so that IE users can get it via console.output
if (!this.output) this.output = new Array();
this.output.push(new String(str));
}
};
window.console = console;
}
In the previous version of FireFox, "var console;" wouldn't get executed. Now it seems to have added some sort of branching/prediction mechanism. Seeing that I may define a variable called console with global scope, it disables window.console.
I fixed this issue by renaming var console; to var cons;
/* IE fix that allows me to still log elsewhere */
if (typeof(console)=="undefined") {
var cons = {
output: null,
log: function (str) {
// we can't emulate the console in IE, but we can cache what's output
// so that IE users can get it via console.output
if (!this.output) this.output = new Array();
this.output.push(new String(str));
}
};
window.console = cons;
}
I still need to test this to make sure it does what I expect in IE, though. I just need to find a copy of IE without a console (I think 9 or below).
I just wish that Firefox would tell you what line of what script disabled the console - that would be nice.
I had the same issue with a Magento e-commerce site (version 1.6.2.0).
I fixed it commenting the following lines in /js/varien/js.js:637
if (!("console" in window) || !("firebug" in console))
{
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
window.console = {};
for (var i = 0; i < names.length; ++i)
window.console[names[i]] = function() {}
}
This fix is only (obviously) for Magento sites.
Turns out the theme developer had added firebug lite to the theme without me knowing. Turning it off fixed the problem.
I think the page you are viewing when trying to log via console.log() has a script in it which overwrites the property window.console.log. Usually this property is preset with a function by the browser but you a script may override it.
First suggestion: Do you use any other dev tools that use console? On Firefox I had the same problem with Firebug running on background without me noticing it, after closing firebug the error went away. Here's a possiple duplicate thread: Firefox Web Console Disabled?
Second, if it is overridden by some script, then one by one disable scripts and see which draws the error.

Categories

Resources