I am working on a C#/JavaScript powered system that previously only worked in Internet Explorer. My job is to make it browser agnostic. It uses a popup engine that I am struggling with.
The code is as follows:
function GetBaseIndexDocument() {
var doc = window;
var i = 0;
while (doc.document.getElementById("22411178-0AB6-42AF-8209-FC753F8B58E2") == null && i < 5) {
i++;
doc = doc.parent;
}
return doc;
}
var _doc = GetBaseIndexDocument(window).document;
var jQ = _doc.parentWindow.$;
In Chrome am getting the following error on the final line of code:
Uncaught TypeError: Cannot read property ‘$’ of undefined
And this one in FireFox:
Error: TypeError: _doc.parentWindow is undefined
I am guessing that c the “parentWindow” property does not exist in either of these (and probably several other) browsers. I am unsure of what to replace it with.
Can anyone point me in the right direction? Your assistance would be greatly appreciated.
I have found online that “defaultView” can be used instead of “parentWindow” in all browsers except IE 8 and lower.