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 ......
ÀàµÄ¶¨ÒåÓÐ3ÖÖ»ù±¾·½·¨:
1¡¢´´½¨²¢ÄÜ·µ»ØÌض¨ÀàÐ͵ĶÔÏóµÄº¯Êý(¹¤³§º¯Êý)È磺
function wu()
{
var w=new object;
o.a=1;
return o;
}ÓÃÕâÖÖ·½Ê½´´½¨¶ÔÏó£ºvar u=wu();
2¡¢´´½¨¹¹Ô캯Êý£¬ÓÃnewʵÀý»¯ÀýÈ磺
function wu()
{this.a=1;}
ÓÃÕâÖÖ·½Ê½´´½¨¶ÔÏó: var u=new wu();
3¡¢ÔÐÍ·½Ê½,À ......
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 ......
1.document.write( " "); Êä³öÓï¾ä
2.JSÖеÄ×¢ÊÍΪ//
3.´«Í³µÄHTMLÎĵµË³ÐòÊÇ:document- >html- >(head,body)
4.Ò»¸öä¯ÀÀÆ÷´°¿ÚÖеÄDOM˳ÐòÊÇ:window- >(navigator,screen,history,location,document)
5.µÃµ½±íµ¥ÖÐÔªËØµÄÃû³ÆºÍÖµ:document.getElementById( "±íµ¥ÖÐÔªËØµÄID號 ").name(»òvalue)
6.Ò»¸ö ......
IE¿ÉÒÔµ÷Óãº
<script type="text/javascript">
// ˵Ã÷£º»ñÈ¡Ò³ÃæÉÏÑ¡ÖеÄÎÄ×Ö
// ÕûÀí£ºhttp://www.CodeBit.cn
function getSelectedText() {
if (window.getSelection) {
// This technique is the most likel ......