Sorting causes IE to throw "A script on this page is causing internet explorer to run slowly"
Sorting causes IE to throw "A script on this page is causing internet explorer to run slowly"
LeadVisionary
Posts: 8Questions: 0Answers: 0
I recently updated jQuery to the latest (from the Google CDN) from version 1.3.2 on an application using DataTables 1.4.9. The application seems to work fine, but on a page with 335 records and a custom sort function it issues a warning in IE, seen in this question:
http://stackoverflow.com/questions/212550/a-script-on-this-page-is-causin
It looks like over 5 million javascript commands are running. Here are the sort functions:
/* Define two custom functions (asc and desc) for columns for content*/
function spanNumericCompare(x, y) {
var x = parseInt($(a).text());
var y = parseInt($(b).text());
return x - y;
}
function spanStringCompare(x, y) {
var x = parseInt($(a).text());
var y = parseInt($(b).text());
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
jQuery.fn.dataTableExt.oSort['span-asc'] = function (a, b) {
return spanNumericCompare(a, b);
};
jQuery.fn.dataTableExt.oSort['span-desc'] = function (a, b) {
return -1 * spanNumericCompare(a, b);
};
jQuery.fn.dataTableExt.oSort['spanString-asc'] = function (a, b) {
return spanStringCompare(a, b);
};
jQuery.fn.dataTableExt.oSort['spanString-desc'] = function (a, b) {
return -1 * spanStringCompare(a, b);
};
The compare functions are trying to extract information from a [number or string] element and sort that way.
I tried upgrading to the latest DataTables (1.7.2), but it appears to still be doing it. What are common ways of troubling-shooting these types of sorting issues with DataTables?
http://stackoverflow.com/questions/212550/a-script-on-this-page-is-causin
It looks like over 5 million javascript commands are running. Here are the sort functions:
/* Define two custom functions (asc and desc) for columns for content*/
function spanNumericCompare(x, y) {
var x = parseInt($(a).text());
var y = parseInt($(b).text());
return x - y;
}
function spanStringCompare(x, y) {
var x = parseInt($(a).text());
var y = parseInt($(b).text());
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
jQuery.fn.dataTableExt.oSort['span-asc'] = function (a, b) {
return spanNumericCompare(a, b);
};
jQuery.fn.dataTableExt.oSort['span-desc'] = function (a, b) {
return -1 * spanNumericCompare(a, b);
};
jQuery.fn.dataTableExt.oSort['spanString-asc'] = function (a, b) {
return spanStringCompare(a, b);
};
jQuery.fn.dataTableExt.oSort['spanString-desc'] = function (a, b) {
return -1 * spanStringCompare(a, b);
};
The compare functions are trying to extract information from a [number or string] element and sort that way.
I tried upgrading to the latest DataTables (1.7.2), but it appears to still be doing it. What are common ways of troubling-shooting these types of sorting issues with DataTables?
This discussion has been closed.
Replies
I'm stuck with the same problem. I have a datatable with about ~600 rows / 3 cols. FF sorts just fine, but IE throws the error message which you have posted above.
If you force the second sort mehtod by doing something like this "if ( false && !window.runtime )" in _fnSort it works for me.
Sorting is still slow, but its better without having the error message ;-)
Good night
Andreas
I'm new to datatables and using the latest version (1.7.4) so I don't have any experience with sorting in IE8 without seeing the messages. But based on the other posts in the thread this seems to be new behavior.
Either way, this is definitely a big problem.
FWIW, I've seen this workaround but not tried it (http://www.picnet.com.au/blogs/Guido/post/2010/03/04/How-to-prevent-Stop-running-this-script-message-in-browsers.aspx) .
changed from [code]if (!window.runtime)[/code]
to [code] if (false && !window.runtime)[/code]