I am using Jon Designs SmoothGallery on a website for one of my clients. The only problem is that I get a script error in IE8 when trying to go to the next image. I have checked this gallery in all major browser, and yet again, IE is the one where it doesn't work.
What a surprise.
I have been trying to find out what the problem was, but I only get an error in the eval-function of the mootools library which the gallery is based on, so no luck there.
Is there any way to set a "All-Exceptions Breakpoint", simular to setting one in Xcode, so that I could find the code that it actually hangs up on? Or does anyone know what is actually going on here?
The site is http://internetvolk.de/tische and the JS file responsible for the gallery is http://internetvolk.de/typo3conf/ext/rgsmoothgallery/res/scripts/jd.gallery1010.js
Thank you in advance,
Tobias Timpe
you are using a really old version of mootools - 0.89 or 1.0, if I am not mistaken. it's eval packed via dean edwards' PACKER, which makes it particularly hard to debug.
the instantiation code itself is somewhat awful and monkey patched:
function startGallery17() {
if (window.gallery17) {
try {
var myGallery17 = new gallery($('myGallery17'), {
timed: false,
showArrows: true,
showCarousel: false,
textShowCarousel: 'Thumbnails',
embedLinks: false,
lightbox: true
});
var mylightbox = new LightboxSmoothgallery();
} catch (error) {
window.setTimeout("startGallery17();", 2500);
}
} else {
window.gallery17 = true;
if (this.ie) {
window.setTimeout("startGallery17();", 3000);
} else {
window.setTimeout("startGallery17();", 100);
}
}
}
window.onDomReady(startGallery17);
the use of strings in setTimeouts causes evals here also, the try blocks will prevent you from getting any useful error feedback either.
if you want to get to the bottom of this, get rid of these hacks, load up say, this version of mootools - https://ajax.googleapis.com/ajax/libs/mootools/1.11/mootools.js - still very old but newer than yours, or if possible, try 1.12 and see if debugging becomes easier.
then get rid of the try/catch blocks, use window.addEvent('domready', fn) to start your code - or if reliant on images being loaded, consider window.addEvent('load', fn) instead.
if all you do on the page is stack up some images with a next/previous, why not use latest mootools with a new plugin - there is NOTHING good about what you have picked.
eg, read this tutorial I wrote on how to do it: http://fragged.org/tutorial-write-a-small-content-slider-class-in-mootools-and-extend-it_1321.html or look on the forge: http://mootools.net/forge/ for something packaged
should be fine with 1.4.5 (latest).
keep in mind the version you are currently using will likely break ie9 and latest gecko
Related
I wrote the following code for debugging puposes:
(function () {
"use strict";
// The initialize function is run each time the page is loaded.
Office.initialize = function (reason) {
$(document).ready(function () {
// Use this to check whether the API is supported in the Word client.
if (Office.context.requirements.isSetSupported('WordApi', 1.1)) {
// Do something that is only available via the new APIs
Office.context.document.addHandlerAsync(Office.EventType.DocumentSelectionChanged, onSelectionChanged);
}
else {
// Just letting you know that this code will not work with your version of Word.
$('#status').html('This code requires WordApi 1.1 or greater.');
}
});
};
var c = 1;
function onSelectionChanged(eventArgs) {
c++;
$('#status').html('onSelectionChanged() call '+c+);
}
})();
This code only sometimes reacts to changes. Sometimes reeaaly slow. Sometimes (I guess, if it is too slow and there have been multiple changes in between, it does not recognize them und prints onSelectionChanged() call 4 after a while, even though, there have been many more changes.
Other times, if I close Word, and open it again, it just works as a charm. Then I close it and open it again, and again, it fails - It is completely inconsistant. Thereby this feature is effectively not usable.
I tested this on different machines, different versions of Windows and it occures independend of the utilization of the system.
Any ideas?
Unfortunately I was not able to repro your issue. The event works quite consistently.
Its not related but is there a specific reason why you are checking the 1.1 requirement set? This event was shipped on the first release of the API so that's not needed.
If you can provide your build number and a sample document and video of whats going on we could investigate in more detail.
thanks!
I've tried to find the solution in previous questions but i couldn't.
I have a web project developed in jquery using requireJS. Everything seems to work fine (in all modern browsers) until i tested in IE9 where there isn't a script working. I tried to find the cause but all i can get is the feedback from dev tool console:
SCRIPT1002: Syntax error libCommon.js, line 10 character 3
SCRIPT445: Object doesn't support this action libEvents.js, line 5
character 2
This is the beginning code of libCommon.js:
//generic JS for all views
define(['jquery'], function ($) {
var LibCommon = function () {};
LibCommon.prototype.hideSubmenu = function() {
$submenu.removeClass('show');
}
LibCommon.prototype.toggleSubmenu = function(tipo) {
const $tipoSubmenu = $('#'+tipo);
this.hideSubmenu();
if (!$tipoSubmenu.hasClass('show')) {
$tipoSubmenu.addClass('show');
} else {
$tipoSubmenu.removeClass('show');
}
};
//and other functions...
And this is the beginning code of libEvents.js:
//generic JS for all views
define(['jquery', 'bootstrap', './libCommon', 'modernizr'], function ($, Bootstrap, LibCommon, Modernizr) {
var common = new LibCommon();
/**
* =================
* TO EXECUTE WHEN INIT
* =================
*/
$( document ).ready(function() {
console.log('initialized all common events');
var common = new LibCommon();
// Fixed header
var stickyNavTop = $('.topmenu').offset().top;
common.fixedNav(stickyNavTop);
$(window).scroll(function() {
common.fixedNav(stickyNavTop);
});
// and other functions or events...
In both errors it's first character of creating a variable/instance of an object after defining all objects/dependencies in requireJS, so it shouldn't be an error. I tried by changing for var common = 0; but error continues appearing in console. It seems that IE9 doesn't like any script. Otherwise, require's instances are working because bootstrap is working properly. Any idea?
Shilly already pointed out in a comment that you should not pass ES6 constructs to IE9. Either write ES5 or use a tool to transpile it.
Now, the error you are getting in libEvents is bizarre because libCommon should not have loaded at all, and consequently the factory of libEvents should not run because one of the dependencies did not load. It is possible to have a module load and later give errors. But I don't recall ever seeing a syntax error in the immediately-interpreted code of a module that did not just cause the load to fail. (The code you are showing is interpreted immediately, even if it is executed later. If you had an eval(string_of_code) in there or a Function(string_of_code) then string_of_code would be interpreted later but this is not something that happens in your code.) I suspect the reason RequireJS goes ahead with executing the factory for libEvents has to do with a problem catching load failures in IE9 and lower. The documentation suggests turning on enforceDefine. I would do this for your code. This won't solve everything but it may help RequireJS detect problems better.
console.log will also probably give you troubles, as explained by this question and answer.
Just getting started with Raphael.
Now I'm finding that paper.remove() is generating a script error:
"SCRIPT5009: 'removed' is undefined
Is this a script bug?
My variable paper is initialized thus:
var paper = new Raphael(document.getElementById('canvas_container'), 500, 500);
My HTML body has:
<div id="canvas_container"></div>
This is more info --
I am using Raphael 2.0 which I just downloaded again. Running IE9. Following is the Raphael JS function that is highlighted as the problem:
R.prototype.remove = function () {
eve("remove", this);
this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);
for (var i in this) {
this[i] = removed(i);
}
};
the line ... removed(i) is highlighted --> SCRIPT5009: 'removed' is undefined
BTW I am new to this forum. Is there a way to respond to a thread other than "Answer Your Question"?
I've run across this a couple of times. The line 4443 method as suggested by sudoko-san does work in browsers but not backwards compatible with IE-7 & 8 (the whole point of using raphael).
Another work around is to implement the following code in your javascript:
try{
paper.remove();
}
catch (error) {
// this catches the error and allows you to proceed along nicely
}
That's it!
I don't know if you've supplied enough information to answer this question.
What version of Raphael are you using?
On what browser?
Is it being loaded up correctly - can you create any Raphael objects?
If all you're doing is deleting the paper, see the fiddle below.
JSFiddle
It seems to work fine for me with Raphael 1.5.2
Hope that helps (even slightly).
I have this script provided by #Felix Kling in this post HERE, but is crashing my IE when I use it; on FF 3.6, Opera, Chrome, Safari work fine.
Any idea why is this happening? A fix maybe?
var ajaxTimeout;
function autorun() {
if ($("#contactForm").is(":visible")){
if(ajaxTimeout) {
clearInterval(ajaxTimeout);
ajaxTimeout = false;
}
}
else if(!ajaxTimeout) {
ajaxTimeout = setInterval("refreshAjax();", 15000);
}
}
$(function autorun() {
setInterval("autorun();", 2000)
});
Thanks,
Cristian.
LE. Sorry, forgot to add details about that.
IE just closes, "encounter an error and needs to close, looking for a solution ...". IE 8.0 Windows7. If I load the page, I cannot open the debugger from the developer tools, but if I open the debugger before I load that page and press Start debug it doesn't show any errors or anything, but the page is not refreshing the grid as it was suppose to.
Here's what you're after:
$(function () {
var ajaxTimeout;
function autorun() {
if ($("#contactForm").is(":visible")){
if(ajaxTimeout) {
clearInterval(ajaxTimeout);
ajaxTimeout = false;
}
}
else if(!ajaxTimeout) {
ajaxTimeout = setInterval(refreshAjax, 15000);
}
}
setInterval(autorun, 2000);
});
IE doesn't at all like named functions used like this, and it's overriding the previously defined one. This is a long-standing bug not fixed until IE9. The core of the problem is that $(function autorun() { is taking over the autorun name, which is just queuing more and more runs of itself.
Also, it's better to pass function references to setInterval() directly, not strings.
I suspect that this is the culprit:
$(function autorun() {
setInterval("autorun();", 2000)
});
That's not really valid javascript. I think it's probably supposed to be something like:
$(document).ready(function() {
setInterval("autorun();", 2000);
});
[edit: there was an error in my suggestion above, and I have corrected it. I was incorrectly assigning the result of setInterval(...) to the variable ajaxTimeout. This ultimately caused the logic inside the main autorun() function to never initiate its interval on refreshAjax(), thus causing the code to appear to "do nothing".]
[edit: some have indicated that my suggestion was offered without enough explanation, so I'll try to provide that here.]
you were declaring function autorun() twice. Once at the top, and again in the bottom section where I've suggested that you should make changes. Both declarations are in the same scope, so the names will collide and behavior will be browser-dependent. Some browsers will let one function "hide" the other, while other browsers will (probably) refuse to compile it.
you have used a named function declaration (the second declaration of autorun) in an "inline" context. This may be allowed by some browsers (and some have suggested that it is actually valid by the standard -- though admittedly I thought it was not), but it will definitely cause problems in IE.
My suggestion changes the second declaration into an anonymous declaration so as to kill two birds with one stone: avoid a name collision, and use syntax that is supported across all browsers.
finally, I introduced the use of $(document).ready(...), because it's standard practice these days, when programming with jQuery. You can read more about it on jQuery's site. Long story short - it is directly equivalent to the $(function() {...}) syntax that you've used, so you can take it or leave it as you please.
I realise this is not the ideal place to ask about this in terms of searchability, but I've got a page whose JavaScript code throws "Stack overflow in line 0" errors when I look at it in Internet Explorer.
The problem is quite clearly not in line 0, but somewhere in the list of stuff that I'm writing to the document. Everything works fine in Firefox, so I don't have the delights of Firebug and friends to assist in troubleshooting.
Are there any standard causes for this? I'm guessing this is probably an Internet Explorer 7 bug or something quite obscure, and my Google-fu is bringing me little joy currently. I can find lots of people who have run into this before, but I can't seem to find how they solved it.
I ran into this problem recently and wrote up a post about the particular case in our code that was causing this problem.
http://cappuccino.org/discuss/2010/03/01/internet-explorer-global-variables-and-stack-overflows/
The quick summary is: recursion that passes through the host global object is limited to a stack depth of 13. In other words, if the reference your function call is using (not necessarily the function itself) was defined with some form window.foo = function, then recursing through foo is limited to a depth of 13.
Aha!
I had an OnError() event in some code that was setting the image source to a default image path if it wasn't found. Of course, if the default image path wasn't found it would trigger the error handler...
For people who have a similar problem but not the same, I guess the cause of this is most likely to be either an unterminated loop, an event handler that triggers itself or something similar that throws the JavaScript engine into a spin.
You can turn off the "Disable Script Debugging" option inside of Internet Explorer and start debugging with Visual Studio if you happen to have that around.
I've found that it is one of few ways to diagnose some of those IE specific issues.
I had this problem, and I solved it. There was an attribute in the <%# Page tag named MaintainScrollPositionOnPostback and after removing it, the error disapeared.
I added it before to prevent scrolling after each postback.
If you came here because you had the problem inside your selenium tests:
IE doesn't like By.id("xyz"). Use By.name, xpath, or whatever instead.
Also having smartNavigation="true" causes this"
I set up a default project and found out the following:
The problem is the combination of smartNavigation and maintainScrollPositionOnPostBack. The error only occurs when both are set to true.
In my case, the error was produced by:
<pages smartNavigation="true" maintainScrollPositionOnPostBack="true" />
Any other combination works fine.
Can anybody confirm this?
Internet Options
Tools
Internet options
Advanced
Navigation section
Click > Disable script debugging
display a notification about every script error
sign in
You will smile !
My was "at line 1" instead but...
I got this problem when using jQuery's .clone method. I replaced these by using making jQuery objects from the html string: $($(selector).html()).
I have reproduced the same error on IE8. One of the text boxes has some event handlers to replace not valid data.
$('.numbersonly').on("keyup input propertychange", function () {
//code
});
The error message was shown on entering data to this text box. We removed event "propertychange" from the code above and now it works correctly.
P.S. maybe it will help somebody
I don't know what to tell you, but the same problem occured with jQuery table sorting and SEARCH.
When there is nothing left in the table, where you are searching a string for example, you get this error too. Even in Google Analytics this error occurs often.
In my case I had two functions a() and b(). First was calling second and second was calling first one:
var i = 0;
function a() { b(); }
function b() {
i++;
if (i < 30) {
a();
}
}
a();
I resolved this using setTimeout:
var i = 0;
function a() { b(); }
function b() {
i++;
if (i < 30) {
setTimeout( function() {
a();
}, 0);
}
}
a();
This is problem with Java and Flash Player. Install the latest Java and Flash Player, and the problem will be resolved. If not, then install Mozilla Firefox, it will auto install the updates required.