zoukankan      html  css  js  c++  java
  • 设置Cookie

    var Site=new Object();
    
    		Site.Cookie={
    
    				_expires:24*3600*1000,
    
    				_domain:'.gdxxb.com',
    
    				set:function(name,value,expires,path,domain){
    
    					expires=new Date(new Date().getTime()+(expires?expires:this._expires));
    					document.cookie=name+"="+escape(value)+";expires="+expires.toGMTString()+";path="+(path?path:"/")+";domain="+(domain?domain:this._domain);
    
    				},
    
    				get:function(name){
    					var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    					if(arr!=null) return unescape(arr[2]);
    					return null;
    				},
    
    				clear:function(name,path,domain){
    					if(this.get(name)) document.cookie=name+"=; path="+(path?path:"/")+"; domain="+(domain?domain:this._domain)+"; expires=Fri, 02-Jan-1970 00:00:00 GMT";
    				}
    		};
    
    		
    		var i = 0,
    			tempi = Site.Cookie.get("random_");
    
    		if(tempi){
    
    
    				i = tempi == 1 ? 2 : 1; //三元操作符(在 1 求值为 TRUE 时的值为 2,在 expr1 求值为 FALSE 时的值为 1。)
    
    				Site.Cookie.set("random_",i);
    
    
    		}else{
    				i = Math.round(Math.random()*1)+1, //随机出现1-2
    
    				Site.Cookie.set("random_",i);
    				
    		}
    
    		
    		var str = document.location.href,
    
    			index = str.indexOf("?"),
    
    			temp = "",
    
    			html= "";
    
    			
    			
    
    			if(index != -1){
    
    				temp = str.substring(index);
    				
    			}
    
    
    
    			html='<iframe id="mainiframe" src="'+i+'/index.html'+temp+'" scrolling="no" allowtransparency="true" frameborder="0" width="100%" height="100%"></iframe>';
    
    		document.getElementById("iframebox").innerHTML=html;
    

      

  • 相关阅读:
    C#使用GZipStream压缩与解压字符串
    C# 参考之方法参数关键字:params、ref及out
    C#中cookie讲解
    WPF中窗口控件的跨线程调用
    vs2010 快捷键大全
    Python线程池
    Python 爬虫修正
    Python 爬虫插件
    Python发现爬虫插件有BUG。
    Python 存在BUG的线程池
  • 原文地址:https://www.cnblogs.com/xupeiyu/p/4571227.html
Copyright © 2011-2022 走看看