Error when closing Iframe in IE - javascript

Making a site that has a videos that are inside Iframe opened with Highslide. It all works great except in IE. When I close the Highslide (and delete the Iframe inside), I get these error messages :
SCRIPT5007: Unable to get property 'random' of undefined or null reference
File: jquery.min.js, Line: 2, Column: 1711
SCRIPT5009: 'jQuery' is undefined
File: flowplayer.min.js, Line: 6, Column: 1
SCRIPT5009: 'flowplayer' is undefined
File: index.php, Line: 20, Column: 4
Occasionally I get a repeating error of:
SCRIPT445: Object doesn't support this action
File: jquery.min.js, Line: 2, Column: 4058
If I reopen the exact same Highslide Iframe right after the error occurs, it'll open just fine without any problems, but still have errors on close. I'm honestly stumped on what to do to fix this.

It sounds like what you've encountered is a weird corner bug with IE. Basically, if an iframe is in another element, in certain cases, when that element is destroyed, the scripts in the iframe will run again, this time with no context - things like Object and Math will just be gone.
Because these are scripts running on a destroyed iframe, I've found the errors to generally be harmless, but I still don't like having them.
I found that something about the interaction between IE and jQuery (1.11.0) seems to cause this. Try emptying out the element containing the iframe using pure DOM calls first:
// Instead of:
//$('div').empty();
// Run this:
var div = $('div')[0];
while (div.firstChild) {
div.removeChild(div.firstChild);
}
No idea why this works, or even if it works in most cases (it worked in my sandbox but not in actual code), and no interest in further diagnosing IE's weird maladies, but it does seem to sometimes eliminate the error and essentially work the same way. :)

In the highslide-full.js file (version 4.1.12), in the afterClose function (somewhere around line 2926) you should find this:
if (this.outline && this.outlineWhileAnimating) this.outline.destroy();
Immediately after that line, add this:
if (this.iframe) {
this.body.removeChild(this.iframe);
}
We've solved our IE9 closing issue with that extra code.

Related

Trying to limit a tampermonkey script to page section

first of, I'm a total, utter newbie. I have to work with this, because nobody in my office is even halfway computer literate. The person who wrote the initial script left the company and we can't get ahold of him anymore.
Now, the problem at hand:
I have a script that's a "look for words and highlight them in garish colour" affair. Now I tried to modify it so that it only runs in a
This is the code:
function Find(node){
if(!node)
node=document.getElementsByTagName('div class="listing__top-info"')[0];
this.rootNode=node;
this.hits=0;
this.selected=0;
this.selection=[];
this.build();
Yet when I run this code, I get this in the log:
"TypeError: document.getElementsByClassName(...)[1] is undefined" (I also don't understand why the [0] gets changed to a [1] here.)
The script is already set to run at document-idle.
The version of the script that works, is set to look for "body", and then marks/highlights as intended.
What am I missing?
Try using querySelector instead:
node = document.querySelector('div.listing__top-info');

JS error on Chrome 57+ for RichFaces application "Cannot read property 'switchToItem' of undefined"

I've a jsp page with tabs. and sometimes an error occurs (when I press a tab) "Cannot read property 'switchToItem' of undefined"
Uncaught TypeError: Cannot read property 'switchToItem' of undefined
at init.__onHeaderClick (packed.js:6102)
at HTMLTableCellElement.<anonymous> (packed.js:1333)
at HTMLTableCellElement.dispatch (jquery.js:846)
at HTMLTableCellElement.eventHandle (jquery.js:722)
as I understand the error happens in packed.js (this is a js-file packed by richfaces of version 4.3.4). I've looked inside this file and found that RichFaces try to find a list of tabs. these tabs are located in property "rf" (element[richfaces.RICH_CONTAINER]), but in moment when I pressed a tab, there was no property.
This bug reproduce in chrome v.57, in version 56 it doesn't reproduce.
Could you help me with some advice, how it can be fixed?
some technical details:
I use xmlns:rich="http://richfaces.org/rich" <rich:tabPanel> tag in my jsp page
in pom.xml <richfaces.version>4.3.4.Final</richfaces.version>
James G, you have a mistake in richfaces.js
richfaces.$$ = function(componentName, element) {
while (element.parentNode) {
var containerId = element.getAttribute(richfaces.RICH_CONTAINER);
if (containerId && containerId !== "" && !!richfaces.COMPONENT_MAP[containerId] && richfaces.COMPONENT_MAP[containerId].component.name == componentName) {
return e.component;
}
else {
element = element.parentNode;
}
}
};
There is no e. You need change it to
...
return richfaces.COMPONENT_MAP[containerId].component;
...
Sorry I don't have the reputation points to make this a comment.
I don't know if google chrome knows about this problem or would be willing to fix it. Our response to this is to patch RichFaces 4.3.7.Final javascript to not use the adhoc dom element property but a global map instead and then deploy our own richfaces jar to our production environment at the end of the month (after testing). I don't have to ability to deploy this to central repo but if you wanted to see the direct changes I made you can see my commits (https://github.com/JamieGHamilton/core). If chrome fixes the problem then this won't be an issue but I'm not counting on that.
So far the changes I made work perfectly in chrome (and other browsers)
Update: I've included the fix found by dennyDarko - thanks for this. My understanding is that the Chrome 58-beta doesn't produce this behavior so for some affected apps, the admins may choose to wait.
This might he an issue of Chrome 57. Try Chrome 58 Beta.
I had the same issue with Richfaces 4.5.17.Final and Chrome 92.
Additionally there was the following log message:
<jsf.non_displayed_message> <WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=null[severity=(ERROR 2), summary=(One or more resources have the target of 'body', but no 'body' component has been defined within the view.), detail=(One or more resources have the target of 'body', but no 'body' component has been defined within the view.)]>
So changing body to h:body in the main XHTML file has resolved the issue.
And h:head contains <h:outputScript name="jsf.js" library="javax.faces"/>

Extjs Intermittent error

Using Extjs 4.1, an intermittent error is occurring.
Sometimes it occurs, but most of the time it does not.
It always occurs when I start the application, so I press F5 and everything returns to normal.
Using this reference to debug the error, I noticed that it occurs at line 29590.
The error message is very generic:
Uncaught TypeError: Cannot read property 'dom' of null
at constructor.finishRender (ext-all-debug-w-comments.js:29590)
at constructor.finishRenderItems (ext-all-debug-w-comments.js:39796)
at constructor.finishRender (ext-all-debug-w-comments.js:40889)
at constructor.finishRenderChildren (ext-all-debug-w-comments.js:44526)
at constructor.afterRender (ext-all-debug-w-comments.js:29331)
at constructor.callParent (ext-all-debug-w-comments.js:6194)
at constructor.afterRender (ext-all-debug-w-comments.js:36521)
at constructor.finishRender (ext-all-debug-w-comments.js:29625)
at constructor.finishRenderItems (ext-all-debug-w-comments.js:39796)
at constructor.finishRender (ext-all-debug-w-comments.js:40889)
Here is an error print
What must be causing this?
I would have made this a comment, but it doesn't fit.
There is a wide variety of reasons I could think of. Most of them are based on asynchronous calls. You definitely have to provide more information for the question to be answerable.
Obviously, me.el is null, which it shouldn't be. So first you have to find which component is causing the problem. For this, you should exchange line 29590 against something like this:
try {
me.container = Ext.get(me.el.dom.parentNode);
} catch(e) {
console.log(me.id);
console.log(me.itemId);
console.log(me.xtype);
...
console.log(me);
throw e;
}
This should give you an idea which component(s) would be affected.
Then show us the code of that component. Also check whether you modify that component's config from outside the component, e.g. from a store load operation or other asynchronous tasks. Plus you should look at whether overrides for the component and its ancestors are loaded from separate JS files - maybe they are sometimes loaded before, sometimes after the finishRender has been called, and fix exactly this error.
These are only a few of the possible reasons.

Ace Editor: Uncaught ReferenceError: window is not defined

I have been looking for a solution to below described issue for a few days but I couldn't find anything helping...
I am using Ace editor on 6 different DIVs on a webpage (so I have 6 editors).
Basically everything works fine, I am able to create them, set them up (language mode, soft tabs, etc.) and manage their content once the user is done.
BUT I keep having the same error message in the console "Uncaught ReferenceError: window is not defined". I get it 6 times, 1 per Ace editor on the page.
Here is the JS I am using. divIdsArray is an array containing the 6 DIVs Ids.
function initAceEditorFields()
{
$(document).ready(function(){
for (var i = 0 ; i < divIdsArray.length ; i++){
var l_arr_splitted = divIdsArray[i].split("_");
var l_str_code = l_arr_splitted[2];//Each div id contains either "js" or "html" which i am retrieving here
var l_ace_editor = ace.edit(divIdsArray[i]);
l_ace_editor.setShowPrintMargin(false);
l_ace_editor.getSession().setUseSoftTabs(false);
l_ace_editor.getSession().setTabSize(4);
l_ace_editor.$blockScrolling = Infinity;
if(l_str_code == "js"){
l_ace_editor.getSession().setMode("ace/mode/javascript");
}else{
l_ace_editor.getSession().setMode("ace/mode/html");
}
}
});
}
I am loading the files: ace.js, mode-javascript.js and mode-html.js from the ace package.
I have tried with ace editor builds: "src-min" and "src-min-noconflict" from the github repo and I tested with Chrome, Mozilla and MS Edge but I always get the same error message.
It is strange as everything seems to be working fine (or at least as I want it too). I just don't want to leave these messages in the console when I go to production.
Any help will be greatly appreciated.
Thank you!
Your ace editor must be using web workers somewhere, then some function called inside a web worker is trying to access "window". The code you've shown us has no references to window. Scrutinize your other interactions with ace to see if you ever pass in a function that references "window" or jquery, or any other dependency in the global scope. If not, then the error in the console is outside your control I suspect.

Internet Explorer line 1 char 1 code 0 error

I'm using jQuery+drupal and some jQuery plugins. All is ok with
Firefox. But in IE's i'm receiving problem like this.
Line: 1
Char: 1
Error: object expected
URL: http://businessway.am
I have included .js files. How to know where is the problem? In which
file? Line 1? Which file?
If you can please check site which I gave before.
You could get this type of errors in case the url of a <script src="...url..."></script> does not return javascript, but some other content (html)
I checked the page, but all scripts with src actually do seem to return javascript. With a bit more digging, it seems that this eval code triggers the error message:
artNoStyleAdding(document)
It looks like it is coming from this script:
<script type="text/javascript">if (Drupal.jsEnabled) {$(document).ready(function(){ window.setTimeout("artNoStyleAdding(document)", 2000);});}</script>
That's the last but one script in the head of the document.
Apperantly you forgot to declare and code the artNoStyleAdding function, whatever it is supposed to do.
I've seen this error come up in IE7 when you have a javascript object with an extra comma on the end.
Example:
var something = {
"one": ["a"],
"two": ["b"],
};
Should be:
var something = {
"one": ["a"],
"two": ["b"]
};
IE8, Chrome, and Firefox don't seem to mind it though.
I had this exact same error, only in IE, when putting comments in a certain spot:
function initMyUI() {
$("#myId") // Don't put comments here.
.delegate("#btnMyButton", "click", _clickDoSomeThings);
};
Depending on your version of IE you'll want to break out the development tools available. You can use Firebug Lite, built in dev tools in IE8 or go the old standby and use Web Developer Express.
The problem has been fixed in IE7 and IE8, but IE6 give's same error.
Updated: Fixed. Sorry :)

Categories