0

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?

  • possible duplicate of [How to detect IE11?](http://stackoverflow.com/questions/17907445/how-to-detect-ie11) – adeneo Feb 01 '14 at 02:18

1 Answers1

1

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;
}
leblma
  • 174
  • 7
  • Why? Code without an **explanation** is not an answer. – Felix Kling Feb 01 '14 at 02:24
  • 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); – leblma Feb 01 '14 at 02:33
  • Good. But this explanation should be part of your answer. Just [edit] it. – Felix Kling Feb 01 '14 at 02:38
  • Plz remove your downvote, I've edited my answer. I'm sorry but I'm new to StackOverflow! – leblma Feb 01 '14 at 02:46
  • 2
    Please re-read what I asked. This is useful but I'm not worrying about detecting IE11, I want my routine to work in IE11 and earlier versions. Why doesn't the DOM in IE react like in FF and other browsers? – user2202543 Feb 01 '14 at 14:48