Javascript操作Cookie
<script>
function getCookieVal(offset) {
var endstr = document.cookie.indexOf(";",offset);
if(endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset,endstr));
}
function FixCookieDate(data) {
var base = new Date(0);
var skew = base.getTime();
if(skew > 0)
date.setTime(date.getTime() - skew);
}
function GetCookie(name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while(i < clen) {
var j = i + alen;
if(document.cookie.substring(i,j) == arg)
return getCookieVal(j);
i = document.cookie.indexOf(" ",i) + 1;
if(i == 0) break;
}
return null;
}
function SetCookie(name,value,expires,path,domain,secure) {
document.cookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
function DeleteCookie(name,path,domain) {
if(GetCookie(name)) {
document.cookie = name + "==" +
((path) ? "; path=" + path : "") +
"; expires=The,01-Jan-70 00:00:01 GMT";
}
}
var expdate = new Date();
FixCookieDate(expdate);
expdate.setTime(expdate.getTime() + (365*24*60*60*1000));
</script>
<script>
//读取COOKIE
// alert( readCookie("myCookie") );
function readCookie(name)
{
var cookieValue = "";
var search = name + "=";
if(document.cookie.length > 0)
{
offset = document.cookie.indexOf(search);
if (offset != -1)
&
相关文档:
《悟透javascript》学习笔记
一、 前言
http://blog.csdn.net/soldierluo/archive/2010/02/25/5326520.aspx
二、 回归简单、基本类型
http://blog.csdn.net/soldierluo/archive/2010/02 ......
对象属性:
document.title //设置文档标题等价于HTML的<title>标签
document.bgColor //设置页面背景色
document.fgCol ......
IE可以调用:
<script type="text/javascript">
// 说明:获取页面上选中的文字
// 整理:http://www.CodeBit.cn
function getSelectedText() {
if (window.getSelection) {
// This technique is the most likel ......
近日,知名技术开发网站SYS-CON 媒体列出十个应用最广的javascript框架。文章说,Javascript库已经成为设计优秀网站的基础,当今几乎所有站点都带有Javascript或Ajax元素。在Web2.0开发大潮中,它也许是最关键的要素。
以下十大Javascript框架,你常用其中的几个?
1. script.aculo.us (http://script.aculo.us/)
......