1

I have below piece of code, which, when tested, does not work in IE8. I have it running on IE11 and Chrome and it runs perfectly. I have debugged the code in IE8 which points at "console.log as a problem area. The most interesting thing is that when I start debugging JS in IE8 - it kicks it and this piece of code start working. Then again, on leaving debugging, closing and re-opening file - same story until you get into debugging))).

jQuery(function () { $('.Response input[type=radio]').change(function () { console.log(this.value) if (this.value == 'Y' || this.value == 'NA' || this.value == 'NS') { $(this).closest('.ui-accordion-content').prev().css("background", "#AADDB2"); } else if (this.value == 'N') { $(this).closest('.ui-accordion-content').prev().css("background", "#FFC5C5"); } }); }); 

Any ideas? Would appreciate yr help. PS. Unfortunately, user kind of "must" use IE8 and upgrading is not an option(((. Thank you in advance)))

2
  • 1
    IE8 chokes on console commands unless the dev tools are open. Commented Feb 28, 2014 at 18:36
  • 2
    stackoverflow.com/questions/690251/… Commented Feb 28, 2014 at 18:37

2 Answers 2

7

you can prevent ie8 errors on console.log with

if (!window.console){ console = {log: function() {}} }; 
Sign up to request clarification or add additional context in comments.

1 Comment

But this will prevent the log from working in IE8 if the dev tool is opened after the page loads.
1

You can add some safety code to define console if it doesn't exist:

if (typeof console === "undefined" || typeof console.log === "undefined") { console.log = function(log_message) { alert(log_message); }; } 

2 Comments

Hmmm, no. User respond to an electronic checklist - he clicks and gets Alert Messages ))))
oh well I thought this was for debugging. In that case, just leave the alert line out, and the function will just do nothing.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.