<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
var array=new Array("1","2","3");
document.write(array+"<br>");
document.cookie="username1="+encodeURI("用户名1");
document.cookie="username2="+encodeURI("用户名2");
document.cookie="username3="+encodeURI("用户名3");
for(i=0;i<10;i++)//1
{document.write(decodeURI("测试用的"+document.cookie[i])+"<br>");
}
if(document.cookie.length>0)
{ start=document.cookie.indexOf("username2=");
if(start!=-1)
{start=start+10;
end=document.cookie.indexOf(";",start);
if(end==-1)
{end=document.cookie.length;
}
document.write(decodeURI(document.cookie.substring(start,end)));
}
}</script>
</head>
这儿存储的cookie通过//1处可知是以单个字符的数组存储的,而实际上cookie是由连续的字符串组成,
应该直接以字符窜的形式存储啊,使用indexOf()表明cookie对象是一个字符窜,使用cookie.length
表明cookie对象一个数组,这个该怎么解释???????
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
var array=new Array("1","2","3");
document.write(array+"<br>");
document.cookie="username1="+encodeURI("用户名1");
document.cookie="username2="+encodeURI("用户名2");
document.cookie="username3="+encodeURI("用户名3");
for(i=0;i<10;i++)//1
{document.write(decodeURI("测试用的"+document.cookie[i])+"<br>");
}
if(document.cookie.length>0)
{ start=document.cookie.indexOf("username2=");
if(start!=-1)
{start=start+10;
end=document.cookie.indexOf(";",start);
if(end==-1)
{end=document.cookie.length;
}
document.write(decodeURI(document.cookie.substring(start,end)));
}
}</script>
</head>
这儿存储的cookie通过//1处可知是以单个字符的数组存储的,而实际上cookie是由连续的字符串组成,
应该直接以字符窜的形式存储啊,使用indexOf()表明cookie对象是一个字符窜,使用cookie.length
表明cookie对象一个数组,这个该怎么解释???????
解决方案 »
- JS中字符串怎么换行
- 问个正则表达式,提取网址和图片或者文字的
- 如果想让一个javascript函数在页面刚打开时就执行,怎么做?
- 有关选择框的问题
- 散分 请问这些url后面带的乱字符=ig+Gwz0ruFJw/DaScYKIkHUEqx3LqFhrTcGnXoR4fjbf6BFd1vm16A==&sid=c993bae7933260c37d16e804a95e4e71有什
- 在线求救关于iframe链接的问题
- foolfish ---->进来接分
- 这个网站很cool!并求这个网站类似的菜单!
- 谁来帮我写这样的一段javascript,今天准备结帐
- 如何利用javascript调用sql?
- 如何在a.php跳转到b.php后刷新b.php的页面
- 图片按钮的一个问题~
这里是一个字符串,
比如
s="abcdefghijk"
for(i=0;i<10;i++)//1
{document.write(decodeURI("测试用的"+s[i])+"<br>");
}打印的是字符串中不同位置的字符,不是数组字符串有length属性啊,不光是数组有