javascript - JS error on IE 9 and 10 - Unable to get property of 1 undefined or null reference -


I'm getting the error only on IE 9 and 10 (I'm not supporting anything below IE9) and the site Works fine on IE 11 and rest of browsers

I am popping up timezone information and displaying it on my page but the script gives me an error on previously given browser versions.

Here is my JS code

  populateLocalTimeInfo: function () {var days = [sun, mon, tue, wed, thu, fri, sat], weekDayNumber = ( New date) .getDay (), weekday = days [weekdays], local time = date.formfold (new date ()); // timezone var regExp = / \ (([^)] +) \) /; Local time + = '(' + regExp.exec (new date) [1] + ')'; $ ('# Local_time'). Html (Replace Preferred (LocalDatetime, [Weekday, Local Time]); },    

On the line I get a script error

  localTime + = '(' + regExp.exec (new date) [1] + ')';   

I'm not completely sure that IE 9 and 10 could not parse this line of code and the properties were unable to get the error. Because of this, my page takes forever to load the content.

I do not see the same script error on IE 11 and the page load is OK.

Your code depends on new date , converts to string Like this example with brackets, chrome in this example: Thursday 24 April 2014 08:50:04 GMT + 0100 (BST)

But on IE10 (at least my locale In), it does not have brackets:

 Thursday 24 April 08:10 UTC + 0100 2014  

Therefore exec back null (Because there was no matching), error therefore

the correct format of that string:

15.9.5.2 Date.prototype.toString ()

This function returns a string value, depending on the content implementation of the string, but in the current time zone To represent the date in a convenient, human-readable form.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -