IE11 function not getting passed constructor - javascript

On pageload i am firing a function that should open a lightbox. In Chrome, FF, Opera, Edge and Safari everything works as it intented. In IE11 however it is not. I am not getting a warning or error in the console so I have no clue what I am doing wrong here.
I stripped the code below to the essential. In Chrome (and other browsers) the console log goes from 1 to 3 to 2. In IE11 i am only getting 1 and I have no idea why it doesn't go to 3 or 2. I thought it had something to do with bind(), but that seems to be supported.
I have to admit I am pretty new with constructors, prototypes and bind.
constructor(el) {
this.$el = $(el);
console.log('1');
this.getLocation = getLocation.bind(this);
this.loadLB();
console.log('2');
}
loadLB() {
const url = new URL(window.location.href);
console.log('3');
this.getLocation('url');
}

Are you using ConstructorMethod? It's also not supported by IE. I don't know if you have used some polyfills to make it work in IE 11.
Besides, IE doesn't support URL() constructor. You can add this polyfill to make URL() work in IE 11:
<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>

Related

Couldn't override console.log in Edge

Here's my code to over-ride console.log(), and works well in Firefox, Chrome, Opera, etc.
var _log = console.log.bind(console);
window.console.log = function (data)
{
_log.call(this,data);
//do something
}
But, latest version of Microsoft Edge throws me an error.
SCRIPT445: Object doesn't support this action
(at line 1 - var _log = console.log.bind(console); to be specific)
How can I make it work on Edge? Why this doesn't work?
When surfing SO about this, saw this answer and cleared all my Edge settings and data. It worked.

AddEventListener in IE does not work

Can someone please advise me why the following code does not work in Internet Explorer 9
document.addEventListener("DOMContentLoaded", function() {
// DEBUG
if (JB_Shopping_Basket.Options.debug) {
console.log('Document loaded');}
JB_Shopping_Basket.Runtime.basket = new JB_Shopping_Basket.Objects.Basket
JB_Shopping_Basket.Functions.refreshProductsTable(JB_Shopping_Basket.Runtime.productsList);});
I'm getting an error that tells me my Basket Object doesn't support property or method 'addEventListener'. It works perfectly it all other browsers but not IE. Any pointers please?

Invalid calling object IE

In FF and Chrome i can set the this value to the location object using bind, with the following code
locationFacade ={
reload: location.reload.bind(location)
}
locationFacade.reload();
Or I can use apply
locationFacade ={
reload: function(){
location.reload.apply(location,arguments); }
}
locationFacade.reload();
However in IE 9 I keep getting "Invalid calling object" when calling locationFacade.reload(); I havent tested every IE but issue happens in IE 11 also. Apply and bind are both supported in IE here and here
This problem seems to be a bug of IE. I tested lots of functions in IE11 (document.writeln, window.alert, etc.), and all of them could be bound, except the members of location. This workaround might help:
locationFacade = {
reload: window.navigate ?
window.navigate.bind(window, location.href) :
location.reload.bind(location)
}

Loading dojo fails in internet explorer 8

It fails after doing this:
<script type="text/javascript" src="/js/dojo-release-1.7.2-src/dojo/dojo.js"></script>
throwing an error on the statement (in this version, 1.7.2, it is line 260)
return new XMLHttpRequest();
being: "TypeError: Object doesn't support this method or property"
The silly thing is that this line is execute a lot of times (maybe even more than 100) without any problem, and it doesn't seem to be dependent on any variables. Unfortunately, at some point it fails. I swapped the line with:
try{
foo = new window.XMLHttpRequest();
return foo;
} catch(e) {
console.log("OUCH, ERROR.");
console.log(typeof window.XMLHttpRequest);
console.log(e);
}
which outputs:
OUCH ERROR.
object
TypeError: Object doesn't support this method or property
I am quite lost, as window.XMLHttpRequest seems to be an object, why can't I 'new' it? Any suggestion on how to debug this would be welcome.
What I find absolutely confusing is that this error only occurs when I go to this page using a link. when I refresh the page using F5, everything works, no errors, nothing.
Moreover, it runs flawless in internet explorer 9, firefox and chrome.
Clear cache completely in-browser
remove any components you have (activex) which are not native
if still issues
run xml-validation on your HTML
make sure the DOCTYPE is correct
check for selfclosing / non-closed tags

Why does CSS3Pie + Prototype 1.6.1 crash Internet Explorer 8

I'm trying to understand why Css3Pie used in conjunction with Prototype 1.6.1 crashes Internet Explorer 8. Why is this happening?
Relevant information
CSS3Pie [source code] is an Internet Explorer behavior (htc) that adds support for CSS3 properties like border-radius, gradients, etc.
The crash only happens in IE8, not IE7 or earlier.
The crash only happens in Prototype 1.6.1 [source code], not Prototype 1.6.0.x
The crash happens immediately on page load, I'm not even able to interact with the page.
The developer is aware of the issue but since he believes it is a Prototype issue (it may be), he may not be eager to fix it. There is both a forum post and GitHub bug report, but neither add much information.
This IE8 crash, which appears to have been fixed in a recent Windows update, was triggered by Prototype's tinkering with DOM object prototypes followed by the application of the CSS3Pie behavior. In Protoype 1.6.1, it can be worked around by setting ElementExtensions and SpecificElementExtensions to false on the Prototype.BrowserFeatures object and modifying the checkDeficiency function to return true immediately.
It's a good start, but then it stops working under other browsers (ie. firefox, chrome). Instead you should add at the beginning of each function (ElementExtensions, SpecificElementExtensions, checkDeficiency) a check for IE 8 then return false for the Extensions anonymous functions and return true for the checkDeficiency function.
ElementExtensions: (function() {
if (isIE8) return false;
...
SpecificElementExtensions: (function() {
if (isIE8) return false;
...
function checkDeficiency(tagName) {
if (isIE8) return true;
...
var isIE8 = (function(){
return ((navigator.userAgent.indexOf('MSIE')!=-1) && (document.documentMode==8));
})();

Categories