Javascript is undefined when project is put live -


i have following code, depending on size of screen determine if re-directed mobile version of site. once on mobile site if choose view desktop version they're redirected desktop version , cookie created, way can continue browse desktop version without being re-directed again.

  $(function() {         if (window.location.href.indexof(".au") > -1) {              var oldurl = document.referrer;              var t = getcookie("frommobile");              if (oldurl.indexof("m.domain") > -1) {                 var date = new date();                 var minutes = 30;                 date.settime(date.gettime() + (minutes * 60 * 1000));                 document.cookie = "frommobile=yes; expires=" + date.togmtstring() + "; path=/";             } else {                 if (t == "") {                     if (screen.width <= 760) {                         window.location = "http://m.domain.com.au/";                     }                 }             }              function getcookie(cname) {                 var name = cname + "=";                 var ca = document.cookie.split(';');                 (var = 0; < ca.length; i++) {                     var c = ca[i];                     while (c.charat(0) == ' ') c = c.substring(1);                     if (c.indexof(name) == 0) return c.substring(name.length, c.length);                 }                 return "";             }         }      }); 

when i'm running on local/staging server works expected, don't javascript errors, yet when pushed live error on following line

var t = getcookie("frommobile"); 

it says getcookie undefined

i'm uncertain why works locally , on staging server, added alerts inside getcookie when running locally/staging , see alerts....

move getcookie definition above "t" var, can prefer use statement expressions when mixing functions, fix problem undefined.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -