Reputation: 1
The site is http://www.basketbasics.com Click on, for instance, Dyes.
This routine uses a jquery module, jquery.sticky.js; the module doesn't appear to be the issue.
The code has language to avoid IE but this doesn't work for IE11. I prefer finding a fix so it works in all recent versions of IE.
On startup, Sidecart() is called.
When you order something (put a quantity in a field then move out of the field) an ajax call is made to add data to a session variable. The callback is callbackSubmit() (The parameter stuff is immaterial here.)
function callbackSubmit(stuff) { if ( navigator.userAgent.indexOf('MSIE') == -1 ) {Sidecart() } }
function Sidecart() {
$("#orderbody").children().detach().remove();
$.ajax({
url:'Sidecart.cfm',
//Sidecart.cfm outputs the session info and returns the data read in the callback
success:function(data){callbakSidecart(data)},
error: function(e){ console.log(e); }
});
}
function callbakSidecart(stuff) {
var x = stuff.split('|');
var z = parseInt(x[0])*3+2;
if ( x[0] > 0 ) {
for ( var i = 2; i<z;i+=3 ){
$('#orderbody').append("<tr><td colspan='2' class='smaller'>" + x[i] + "</td></tr><tr><td class='smaller'>" + x[i+1] + "</td><td class='smaller'>" + x[i+2] + "</td></tr><tr><td colspan='2'><hr></td></tr>");
}
$('#orderbody').append('<tr><td colspan="2">Total: ' + x[1] + '</td></tr>');
}
}
The structure it is referencing is a table with a tbody id=orderbody
Suggestions for better code are welcome but I'm not concerned here about how tables are bad, etc. The question is why does it work in FF, Chrome, Opera and Safari but doesn't work right in IE?
Upvotes: 0
Views: 179
Reputation: 174
IE11 no longer reports as MSIE, according to this list of changes, it's intentional to avoid mis-detection. What you can do if you really want to know it's IE is to detect the Trident/ string in the user agent if navigator.appName returns Netscape, something like (the untested);
So, use this function
function getInternetExplorerVersion()
{
var rv = -1;
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
else if (navigator.appName == 'Netscape')
{
var ua = navigator.userAgent;
var re = new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}
Upvotes: 1