私は JavaScript Cookie に取り組んでおり、私のCookie 名は
ssecname
で
あるため、このコードを使用して Cookie を検索したい
function readcookie() {
var allcookies = document.cookie;
var cookiearray = allcookies.split(';');
for(var i = 0; i<=cookiearray.length; i++)
{
name = cookiearray[i].split('=')[0];
coo_glo_value = cookiearray[i].split('=')[1];
alert(name); /* here it shows name value is equal to ssecname but not comparing below */
if(name == "ssecname") /* i have tried === */
{
alert('here you go');
}
}
}
なぜ文字列を比較しないのかわかりませんが、いつ比較しますか
if(name != "ssecname")
{
alert('here you go');
}
ここに出力が表示されるので、なぜそれが起こっているのか理解できませんか?? 私を助けて、比較する他の方法を親切に教えてください..事前にTahnks :)