DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> sso跨域寫cookie的一段js腳本(推薦)
sso跨域寫cookie的一段js腳本(推薦)
編輯:關於JavaScript     
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script>
 var setcookitarray = "";
 setcookitarray = "[\"http://passport.a.com/main/setCookie.do?domain=\",\"http://passport.a.com/main/setCookie/main/setCookie.do?domain=.b.cn\",\"http://passport.a.com/main/setCookie/main/setCookie.do?domain=.c.com\",\"http://passport.a.com/main/setCookie/main/setCookie.do?domain=.d.cn\"]";
 setcookitarray = eval(setcookitarray); 
 var setcookitarrayln = setcookitarray.length; 
 //alert(setcookitarrayln);
 var notifyurl_list=setcookitarray;
 var ll = setcookitarrayln;
 var params="yqVg1ennsNnxydEq4azcAP6TjhR90QCEUtB7gs45H08ltXBUNeoy_GczVyqC6cvZEwPGN0Al8XWKDsIt60YO1QsUlbK0Fip73Xz@7djs3ZmhBbAdanMbUH1Y@MVD2@@keR0S7njF5xiy@m6zaRWYNMbJ23jLDSrvEtMj0BExfYvFFe@twp3RHfD41dJOQzWz@nf8i@tJB12hNLIG4oW0eA==";
 var failuretime=2678400;
 var backurl="http://www.test.com";
 //alert("1111");
 
 loginALL(notifyurl_list, ll-1, backurl, params,failuretime);
 //alert("2222");
 function loginALL(notifyurl_list,num,backurl,params,failuretime) {
    var u = notifyurl_list[num];
		 alert("url:"+(num)+"-"+u);
    if (typeof u != "undefined") {
		  //alert("4444:"+notifyurl_list[num]);
      var url = notifyurl_list[num]+"&failuretime="+failuretime+"&val="+params;
			//alert("url:"+url);
			
			//動態生成script腳本標簽執行url頁面
			var login=request("loginScript"+num,url);
			num--;
      if (num < 0) {
				
        window.setTimeout(function() {
          window.location.href = backurl;
        }, 2000);
				
      }
			else
			{
				loginALL(notifyurl_list, num, backurl, params,failuretime);
			}
     
      
    }
 }
 
 
 
 function request(id,url){
   oScript = document.getElementById(id);
   var head = document.getElementsByTagName("head").item(0);
   if (oScript) {
    head.removeChild(oScript);
   }
   oScript = document.createElement("script");
   oScript.setAttribute("src", url);
   oScript.setAttribute("id",id);
   oScript.setAttribute("type","text/javascript");
   oScript.setAttribute("language","javascript");
   head.appendChild(oScript);
   return oScript;
}
 

</script>


<body>

</body>

主要通過 遞歸調用 和 動態創建script標簽來實現頁面的調用。

以上這篇sso跨域寫cookie的一段js腳本(推薦)就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved