Javascript character encoding in Internet explorer -
i have script compares array of strings in hebrew hebrew text on website. script works correctly in browsers except versions of internet explorer. way have to debug log browser user agent when try reproduce issue in same ie version, seems work correctly on local machine.
the relevant part of script
var cities = ['אילת','ים המלח','תל אביב','באר שבע','חיפה','נתניה']; if (pids.length) { (var = 0; < cities.length; i++) { if (pids[0].search(cities[i]) > -1){ userinfo.city = cities[i]; break; } } //for debugging if (userinfo.city =='') log += navigator.useragent; }
i know pids has right value because other information script collects handled correctly. problem in string search.
here's sample of user agents logged:
mozilla/5.0 (windows nt 6.1; trident/7.0; slcc2; .net clr 2.0.50727; .net clr 3.5.30729; .net clr 3.0.30729; media center pc 6.0; .net4.0c; .net4.0e; rv:11.0) gecko mozilla/5.0 (windows nt 6.1; wow64; trident/7.0; slcc2; .net clr 2.0.50727; .net clr 3.5.30729; .net clr 3.0.30729; media center pc 6.0; .net4.0c; .net4.0e; rv:11.0) gecko mozilla/5.0 (compatible; msie 10.0; windows nt 6.2; wow64; trident/6.0; .net4.0e; .net4.0c; bri/2) mozilla/5.0 (compatible; msie 9.0; windows nt 6.1; wow64; trident/5.0; slcc2; .net clr 2.0.50727; .net clr 3.5.30729; .net clr 3.0.30729; media center pc 6.0; .net4.0c; .net4.0e) mozilla/5.0 (windows nt 6.3; wow64; trident/7.0; .net4.0e; .net4.0c; .net clr 3.5.30729; .net clr 2.0.50727; .net clr 3.0.30729; mcafee; rv:11.0) gecko mozilla/5.0 (windows nt 6.3; trident/7.0; touch; .net4.0e; .net4.0c; .net clr 3.5.30729; .net clr 2.0.50727; .net clr 3.0.30729; tablet pc 2.0; rv:11.0) gecko
edit: realize didn't adequately explain happens when script fails. when script fails userinfo.city empty. cannot happen in practice because pids[0] have 1 of values in it.
the value in pids[0] retrieved scraping dom. value contains correct because it's used in other parts of program work correctly.
the document.characterset
of site script runs utf-8
the script encoded in utf-8 , loaded via google tag manager.
Comments
Post a Comment