- UID
- 399154
- 在线时间
- 小时
- 积分
- 683
- 帖子
- 离线
- 18735 天
- 注册时间
- 2007-9-20
|
假设当前访问路径是: www.123.com
在该页上的登陆连接:
- <a href="javascript:popCoverDiv();javascript:Do.Login('Login','http://www.123.com/user/login.php');">登陆</a>
复制代码
这样能正常加载登陆窗口;
登陆窗口加载成功
而我将用户中心绑定了二级域名后,即连接代码改为如下:
- <a href="javascript:popCoverDiv();javascript:Do.Login('Login','http://member.123.com/login.php');">登陆</a>
复制代码
这样的话登陆的窗口就加载不成功:
登陆窗口加载不成功
其实第一种加载成功也只限于该域名下,但是要到比如某频道为:mus.123.com 这样的地方的时候,加载也是不成功的。
故特来向大家讨教下,以下是JS代码:
- //顶部登陆状态
- /*
- function CheckLoginh(){
- if (getcookiename("userid")){
- document.getElementById("unmenulogin").style.display="none";
- document.getElementById("ismenulogin").style.display="";
- document.getElementById("ismenuloginname").innerHTML=getcookiename("username");
- document.getElementById("ismenuusergroup").innerHTML=getcookiename("groupname");
- document.getElementById("ismenuuserpoint").innerHTML=getcookiename("userpoint");
- document.getElementById("ismenulasttime").innerHTML=getcookiename("LastTimes");
- }else{
- document.getElementById("ismenulogin").style.display="none";
- document.getElementById("unmenulogin").style.display="";
- }
- }
- */
- function CheckLoginh(){
- var taget_obj = document.getElementById('loginform');
- myajax = new DedeAjax(taget_obj,false,false,'','','');
- myajax.SendGet2("http://member.123.com/logins.php");
- DedeXHTTP = null;
- }
-
- //输入框状态
- function inputAutoClear(ipt)
- {
- ipt.onfocus=function()
- {if(this.value==this.defaultValue){this.value='';}};
- ipt.onblur=function()
- {if(this.value==''){this.value=this.defaultValue;}};
- ipt.onfocus();
- }
- //提示层setTimeout("document.all.tishi.style.visibility = 'hidden'","50000");
- function G(id){
- return document.getElementById(id);
- };
-
- function GC(t){
- return document.createElement(t);
- };
-
- String.prototype.trim = function(){
- return this.replace(/(^\s*)|(\s*$)/g, '');
- };
-
- function isIE(){
- return (document.all && window.ActiveXObject && !window.opera) ? true : false;
- }
-
- function getBodySize(){
- var bodySize = [];
- with(document.documentElement) {
- bodySize[0] = (scrollWidth>clientWidth)?scrollWidth:clientWidth;
- bodySize[1] = (scrollHeight>clientHeight)?scrollHeight:clientHeight;
- }
- return bodySize;
- }
- //显示隐藏层
- function put_layer(no)
- {
- if ( !!no )
- {
- obj = document.getElementById("put_layer" + no);
- if ( obj.style.display != "none" ) {
- obj.style.display = "none";
- }
- else {
- obj.style.display = "block";
- }
- }
- }
- function popCoverDiv(){
- if (G("cover_div")) {
- G("cover_div").style.display = '';
- } else {
- var coverDiv = GC('div');
- document.body.appendChild(coverDiv);
- coverDiv.id = 'cover_div';
-
- with(coverDiv.style) {
- position = 'absolute';
- background = '#000000';
- left = '0px';
- top = '0px';
- var bodySize = getBodySize();
- width = bodySize[0] + 'px'
- height = bodySize[1] + 'px';
- zIndex = 98;
- if (isIE()) {
- filter = "Alpha(Opacity=80)";
- } else {
- opacity = 0.8;
- }
- }
- }
- }
- //登陆AJAX
- var AddJs= {"JsNull":function() {}
- }
- AddJs.JsNull();
- function AjaxObj()
- {
- var XmlHttp;
- try {
- XmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
- } catch (e) {
- try {
- XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
- try {
- XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
- } catch (e) {
- XmlHttp = false;
- }
- }
- }
- if (!XmlHttp)
- {
- try {
- XmlHttp = new XMLHttpRequest();
- } catch (e) {
- XmlHttp = false;
- }
- }
- return XmlHttp;
- }
- var Dialog = {
- "init":""
- ,"dialogBox":null
- ,"defWidth":320
- ,"width":0
- ,"show":function(title,url) {
- if (this.dialogBox == null) {
- this.create();
- }
- this.setWidth(this.defWidth);
- this.dialogBox.style.display = "block";
- this.setTitle(title);
- this.setLoading();
- Drag.init(document.getElementById("draghead"), this.dialogBox);
- this.dialogBox.onDragEnd=function(x,y){
- Dialog.dialogBox.ox=x-Dialog.getRange().left;
- Dialog.dialogBox.oy=y-Dialog.getRange().top;
- }
- this.center();
- this.loadContent(url);
- }
- ,"setWidth":function(width) {
- if (width != this.width) {
- this.width = width;
- this.dialogBox.style.width = width+"px";
- this.center();
- }
- }
- ,"loading":null
- ,"setLoading":function() {
- this.setContent("<p class='loading'><img src='/images/loading17.gif' border='0' alt='数据加载中...' /></p>");
- }
- ,"clearLoading":function() {
- if (this.loading != null) {
- clearTimeout(this.loading);
- this.loading = null;
- }
- }
- ,"loadContent":function(url) {
- var time = "?"+(new Date().getTime());
-
- var Ajax = new AjaxObj();
- Ajax.open("POST",url, true);
- Ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded");
- Ajax.onreadystatechange=function() {
- if (Ajax.readyState==4&&Ajax.status==200) {
- document.getElementById("dialogBox_content").innerHTML=Ajax.responseText;
- }
- }
- Ajax.send(null);
- }
- ,"setContent":function(content) {
- document.getElementById("dialogBox_content").innerHTML = "<div class='dialogBox_Content'>"+content+"</div>";
- }
- ,"close":function() {
- if (this.dialogBox != null) {
- this.dialogBox.style.display = "none";
- G("cover_div").style.display = 'none';
- }
- }
- ,"setTitle":function(html) {
- document.getElementById("dialogBox_title").innerHTML = html;
- }
-
- ,"create":function() {
- var d = document.createElement("DIV");
- d.id = "dialogBox";
- var html = '<div class="dialogBox" style="cursor:pointer"><div id="draghead" class="title"><h2 id="dialogBox_title"></h2><span><a onclick="" href="javascript:Dialog.close();" ><img src="/templates/login02_div.gif" style="cursor:pointer" height="34" width="20" border="0" alt="关闭窗口" /></a></span></div><div class="content" id="dialogBox_content"></div></div>';
- d.innerHTML = html;
-
- document.body.appendChild(d);
- this.dialogBox = document.getElementById("dialogBox");
- this.center();
- window.onscroll=Dialog.onBodyScroll;
- }
- ,"onBodyScroll":function(){
- var range=Dialog.getRange();
- var top = (range.top+Dialog.dialogBox.oy);
- var left = (range.left+Dialog.dialogBox.ox);
- if (top < 5) { top = 5; }
- if (left< 5) { left = 5; }
- Dialog.dialogBox.style.top=top +"px";
- Dialog.dialogBox.style.left=left +"px";
- }
- ,"center":function() {
- var range=Dialog.getRange();
- var left = (range.width-this.width)/2;
- var top = (range.height-300)/2 ;
- this.dialogBox.ox= left;
- this.dialogBox.oy= top;
- if (range.left > left) { left = range.left+left;}
- if (range.top > top ) { top = range.top +top;}
- this.dialogBox.style.left = left + "px";
- this.dialogBox.style.top = top + "px";
- }
- ,"move":function(left, top) {
- this.dialogBox.ox= left;
- this.dialogBox.oy= top;
- this.dialogBox.style.left = left + "px";
- this.dialogBox.style.top = top + "px";
- }
- ,"getRange":function() {
- var top = document.documentElement.scrollTop;
- var left = document.documentElement.scrollLeft;
- var height = document.documentElement.clientHeight;
- var width = document.documentElement.clientWidth;
- if (top==0 && left==0 && height==0 && width==0) {
- top = document.body.scrollTop;
- left = document.body.scrollLeft;
- height = document.body.clientHeight;
- width = document.body.clientWidth;
- }
- return {top:top ,left:left ,height:height ,width:width } ;
- }
- }
- var Drag={
- "obj":null,
- "init":function(a, aRoot){
- a.onmousedown=Drag.start;
- a.root = aRoot;
- if(isNaN(parseInt(a.root.style.left)))a.root.style.left="0px";
- if(isNaN(parseInt(a.root.style.top)))a.root.style.top="0px";
- a.root.onDragStart=new Function();
- a.root.onDragEnd=new Function();
- a.root.onDrag=new Function();
- },
- "start":function(a){
- var b=Drag.obj=this;
- a=Drag.fixE(a);
- var c=parseInt(b.root.style.top);
- var d=parseInt(b.root.style.left);
- b.root.onDragStart(d,c,a.clientX,a.clientY);
- b.lastMouseX=a.clientX;
- b.lastMouseY=a.clientY;
- document.onmousemove=Drag.drag;
- document.onmouseup=Drag.end;
- return false;
- },
- "drag":function(a){
- a=Drag.fixE(a);
- var b=Drag.obj;
- var c=a.clientY;
- var d=a.clientX;
- var e=parseInt(b.root.style.top);
- var f=parseInt(b.root.style.left);
- var h,g;
- h=f+d-b.lastMouseX;
- g=e+c-b.lastMouseY;
- b.root.style.left=h+"px";
- b.root.style.top=g+"px";
- b.lastMouseX=d;
- b.lastMouseY=c;
- b.root.onDrag(h,g,a.clientX,a.clientY);
- return false;
- },
- "end":function(){
- document.onmousemove=null;
- document.onmouseup=null;
- Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style.left),parseInt(Drag.obj.root.style.top));
- Drag.obj=null;
- },
- "fixE":function(a){
- if(typeof a=="undefined")a=window.event;
- if(typeof a.layerX=="undefined")a.layerX=a.offsetX;
- if(typeof a.layerY=="undefined")a.layerY=a.offsetY;
- return a;
- }
- };
- var Do = {"init": ""
- ,"Login":function(sTitle,sUrl) {
- Dialog.show( sTitle, sUrl);
- }
- }
- //cookie读写脚本
- function GetCookieVal(offset)
- {
- var endstr = document.cookie.indexOf (";", offset);
- if (endstr == -1)
- endstr = document.cookie.length;
- return unescape(document.cookie.substring(offset, endstr));
- }
- function SetCookie(name, value)
- {
- var expires = new Date();
- expires.setTime(expires.getTime() + 12 * 30 * 24 * 60 * 60 * 1000);
- document.cookie = name + "=" + value + ";expires=" + expires.toGMTString();
- }
- function DelCookie(name)
- {
- var exp = new Date();
- exp.setTime (exp.getTime() - 1);
- var cval = GetCookie (name);
- document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
- }
- 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;
- }
- // Smooth Scroll Back to Top
- var scrollToTop = function(){ $('a[@href=#top]').click(function(){ backToTop(); return false;} ) };
- function backToTop() {
- var x1 = x2 = x3 = 0;
- var y1 = y2 = y3 = 0;
- if (document.documentElement) {
- x1 = document.documentElement.scrollLeft || 0;
- y1 = document.documentElement.scrollTop || 0;
- }
- if (document.body) {
- x2 = document.body.scrollLeft || 0;
- y2 = document.body.scrollTop || 0;
- }
- x3 = window.scrollX || 0;
- y3 = window.scrollY || 0;
- var x = Math.max(x1, Math.max(x2, x3));
- var y = Math.max(y1, Math.max(y2, y3));
- window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));
- if (x > 0 || y > 0) {
- window.setTimeout("backToTop()", 30);
- }
- }
- //网页报错
- function openwinx(url,name,w,h)
- {
- window.open(url,name,"top=100,left=400,width=" + w + ",height=" + h + ",toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no")
- }
- //显示隐藏分页层
- function ss_layer(no)
- {
- if ( !!no )
- {
- obj = document.getElementById("ss_layer" + no);
- obj2 = document.getElementById("sss" + no);
- if ( obj.style.display != "none" ) {
- obj2.className='feny';
- obj.style.display = "none";
-
- }
- else {
- obj2.className='fenyon';
- obj.style.display = "block";
- }
- }
- }
- // 显示/隐藏工具导航层
- function onClickDiv(DivId)
- {
- if(document.all[DivId].style.display=='none')
- { document.all[DivId].style.display=''; }
- else
- { document.all[DivId].style.display='none'; }
- return 0;
- }
复制代码
[[i] 本帖最后由 136com 于 2009-12-29 15:18 编辑 ] |
|