一段登錄新浪微博的IE6的javascript腳本總是被瀏覽器aborted的解決辦法

var is_login;
function showLogin(){
	var html = '';
	if(userinfo.dquid.uid){
		is_login=1;
		
		html += '<div class="weiboInfo"><p class="uname"><a title="" target="_blank" href="http://weibo.com/'+userinfo.dquid.uid+'"><span class="v" id="wf_a2">'+userinfo.dquid.screen_name+'</span></a></p><p class="udesc" id="udesc"></p><p class="ufans">粉絲<a id="fans"></a>人  微博<a id="statuses_count"></a>條</p></div><div class="avatar"><a title="" target="_blank" href="http://weibo.com/'+userinfo.dquid.uid+'"><img src="'+userinfo.dquid.img+'" width="50" height="50" /></a></div>';
		jQuery(function(){//微博
		$.getJSON("http://t.auto.sina.com.cn/interface/auto_t_users_show_by_uids.php?callback=?", { "ids":userinfo.dquid.uid},
		function(data){
		jQuery("#udesc").html(data[0].description);
		jQuery("#fans").html(data[0].followers_count);//粉絲數量
        jQuery("#statuses_count").html(data[0].statuses_count);
			});
		})
		
		jQuery(".weiboName, .userName span").html('@'+userinfo.dquid.screen_name);
        if (userinfo.dquid.screen_name.replace(/[^\x00-\xff]/g, "**").length <= 10) {
            jQuery(".weiboName").css('font-size', '18px');
            jQuery(".weiboName").css('line-height', '18px');
        }
		var logout = '<a href="http://weibo.com/logout.php?backurl=http://t.auto.sina.com.cn/wbk/">退出>></a>';
		jQuery('.myWeibo .title').prepend(logout);
		jQuery('.specialLogo .weiboName').css('visibility', 'visible');
		
	}else{
		is_login=0;
		
		html = '<a class="loginWeibo" href="javascript:void(0)" οnclick="openLogin();return false;"></a> <span class="registerWeibo">還沒有新浪微博? <a href="http://weibo.com/reg.php?ps=u3〈=zh">馬上註冊</a></span>';
		jQuery('.specialLogo .weiboName').css('visibility', 'hidden');

	}
	jQuery("#login").empty().html(html);
	
}
showLogin();
//登錄顯示結束
//登錄判斷
function sub()
{
	if(jQuery(".uid").attr("value")=="")
	{
		//alert("請輸入用戶名");
		//$(".uid").get(0).focus();
		//return false;
	}
	if(jQuery(".pwd").attr("value")=="")
	{
		//alert("請輸入密碼");
		//jQuery(".pwd").get(0).focus();
		//return false;
	}
	window.setTimeout("sendsso()",1);
	//sendsso();	
}
function sendsso(){      
   var res = sinaSSOController.login($(".uid").attr("value"),$(".pwd").attr("value")); 
   if(res && (navigator.userAgent.indexOf("MSIE")!=-1)){
	   //window.clearTimeout(function(){},1);
	   //alert("登錄成功!");
   }
}
function logoutSSO(){
    sinaSSOController.logout();    
}
//登錄判斷結束

如上所示代碼,在ff,ie>=7,,chrome瀏覽器工作都正常,唯獨在IE6中不正常,但是沒有腳本錯誤提示,用httpwatch抓包觀察後,會發現他的通信被不是200,而是被阻止,



此處,查了一部分資料但是沒有找到根本原因,只從網上找到一些臨時的解決辦法,

1)將sendsso(),放到setTimeout()中執行,

2) 換成xmlhttp異步加載,

 如有知道根本原因的歡迎在評論中給出答案!

發佈了44 篇原創文章 · 獲贊 8 · 訪問量 12萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章