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 ......
Definition and Usage
定义与用法The constructor property is a reference to the function that created an object.
constructor属性是所建立对象的函数参考Syntax
语法object.constructor
Example 1
举例
In this example we will show how to use the constructor property:
在这个举例中我们将展示如何使用cons ......
<SCRIPT language=javaScript>
<!--
now = new Date(),hour = now.getHours()
if(hour < 6){document.write("凌晨好!")}
else if (hour < 9){document.write("早上好!")}
else if (hour < 12){document.write("上午好!")}
else if (hour < 14){document.write("中午好!")}
else if (hour &l ......
近日,知名技术开发网站SYS-CON 媒体列出十个应用最广的javascript框架。文章说,Javascript库已经成为设计优秀网站的基础,当今几乎所有站点都带有Javascript或Ajax元素。在Web2.0开发大潮中,它也许是最关键的要素。
以下十大Javascript框架,你常用其中的几个?
1. script.aculo.us (http://script.aculo.us/)
......
判断浏览器类型
<SCRIPT language=javascript>
if(navigator.appVersion.indexOf("MSIE 6.") != -1 ){
window.location = "111.htm" ;
}
</SCRIPT>
按钮背景图片替换
<input type=button style="background-image:url(a.gif)" value=test onmouseover="this.style.backgroundImage='url(b.gif ......