Лови пример для всех browser'ов.> function getenv(i){ > if (!i.length) { return false; } > qStr = document.location.href; > strpos = qStr.indexOf("?"+i+"="); > if ( strpos ==-1 ) { strpos = qStr.indexOf("&"+i+"="); } > if ( strpos == qStr.length || strpos ==-1 ) { return false; } > val = qStr.substring( (strpos+i.length)+2, qStr.length); > strpos = val.indexOf("&"); > if ( strpos !=-1 ) { val = val.substring(0, strpos ); } > if ( !val.length ) { return false; } else { return val; } > }
Можно по-короче: function getenv1(n) { p = document.location.href.split("?"); p = p[1].split("&"); for (i in p) { t = p[i].split("="); if (t[0] == n) return t[1] } } |