当前位置:Gxlcms > JavaScript > sso跨域写cookie的一段js脚本(推荐)

sso跨域写cookie的一段js脚本(推荐)

时间:2021-07-01 10:21:17 帮助过:31人阅读

  1. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  2. <script>
  3. var setcookitarray = "";
  4. 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\"]";
  5. setcookitarray = eval(setcookitarray);
  6. var setcookitarrayln = setcookitarray.length;
  7. //alert(setcookitarrayln);
  8. var notifyurl_list=setcookitarray;
  9. var ll = setcookitarrayln;
  10. var params="yqVg1ennsNnxydEq4azcAP6TjhR90QCEUtB7gs45H08ltXBUNeoy_GczVyqC6cvZEwPGN0Al8XWKDsIt60YO1QsUlbK0Fip73Xz@7djs3ZmhBbAdanMbUH1Y@MVD2@@keR0S7njF5xiy@m6zaRWYNMbJ23jLDSrvEtMj0BExfYvFFe@twp3RHfD41dJOQzWz@nf8i@tJB12hNLIG4oW0eA==";
  11. var failuretime=2678400;
  12. var backurl="http://www.test.com";
  13. //alert("1111");
  14. loginALL(notifyurl_list, ll-1, backurl, params,failuretime);
  15. //alert("2222");
  16. function loginALL(notifyurl_list,num,backurl,params,failuretime) {
  17. var u = notifyurl_list[num];
  18. alert("url:"+(num)+"-"+u);
  19. if (typeof u != "undefined") {
  20. //alert("4444:"+notifyurl_list[num]);
  21. var url = notifyurl_list[num]+"&failuretime="+failuretime+"&val="+params;
  22. //alert("url:"+url);
  23. //动态生成script脚本标签执行url页面
  24. var login=request("loginScript"+num,url);
  25. num--;
  26. if (num < 0) {
  27. window.setTimeout(function() {
  28. window.location.href = backurl;
  29. }, 2000);
  30. }
  31. else
  32. {
  33. loginALL(notifyurl_list, num, backurl, params,failuretime);
  34. }
  35. }
  36. }
  37. function request(id,url){
  38. oScript = document.getElementById(id);
  39. var head = document.getElementsByTagName("head").item(0);
  40. if (oScript) {
  41. head.removeChild(oScript);
  42. }
  43. oScript = document.createElement("script");
  44. oScript.setAttribute("src", url);
  45. oScript.setAttribute("id",id);
  46. oScript.setAttribute("type","text/javascript");
  47. oScript.setAttribute("language","javascript");
  48. head.appendChild(oScript);
  49. return oScript;
  50. }
  51. </script>
  52. <body>
  53. </body>

主要通过 递归调用 和 动态创建script标签来实现页面的调用。

以上这篇sso跨域写cookie的一段js脚本(推荐)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

人气教程排行