一段登录新浪微博的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万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章