I'm teaching myself javascript, as we have decided to develop our own analytics tracking to integrate into our analytics db. We had previously been using a 3rd party to provide tracking technology. So, this is my first dive into javascript, with my experience mostly in VB .net/asp and SQL. I was making good progress, and then ran into this issue. Javascript tested through: var broken_info = cookieValue.split(":")
When the browser executes this line I get: cookieValue.split is not a function in Firefox error console.
Here is the complete javascript (which is housed in a js file) and is called from the javascript at this URL:
http://www.searchmarketingtools.com/tester.html?source=testengine&kw=test+keyword
//<!-- Tracking Code v1.00 - All rights reserved -->
function Randomstring()
{
var chararr="abcdefghijklmnopq
rstuvwxyz0
123456789A
BCDEFGHIJK
LMNOPQRSTU
VWXYZ"
var rndstr=""
for(i=0;i<10;i++)
{
rndstr=rndstr+chararr.char
At(Math.ro
und(Math.r
andom()*62
)-1)
}
id = rndstr;
return rndstr;
}
function Setcookie()
{
var _d=new Date();
_d.setTime(_d.getTime()+31
536000000)
;
expires=_d
var fcnv = "SMTstatbuilder="+"id:"+Ra
ndomstring
()+"; path=/; expires="+expires;
document.cookie = fcnv;
}
function readCookie(name) {
if (document.cookie == '') {
// there's no cookie, so go no further
return false;
} else {
// there is a cookie
var firstChar, lastChar;
var theBigCookie = document.cookie;
firstChar = theBigCookie.indexOf(name)
;
// find the start of 'name'
if(firstChar != -1) {
// found cookie
firstChar += name.length + 1;
// skip 'name' and '='
lastChar = theBigCookie.indexOf(';', firstChar);
// Find the end of the value string (i.e. the next ';').
if(lastChar == -1) lastChar = theBigCookie.length;
return unescape(theBigCookie.subs
tring(firs
tChar, lastChar));
} else {
// If there was no cookie of that name, return false.
return false;
}
}
}
var id
var cookieValue = readCookie('SMTstatbuilder
');
if(cookieValue == "false"){Setcookie}
else {
var broken_info = cookieValue.split(":")
id = broken_info[1];
}
**************************
**********
**********
**********
**********
From all the reference/documentation I have reviewed, split is a valid string function. Why am I getting this error?