首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

求JS高手,把上面的JS改成兼容IE,火狐和Goolge浏览器

2012-08-02 
求JS高手,把下面的JS改成兼容IE,火狐和Goolge浏览器//------GetMessageCount.js Begin-------------------

求JS高手,把下面的JS改成兼容IE,火狐和Goolge浏览器
//------GetMessageCount.js Begin----------------------
var oPopup = window.createPopup();
var popTop=20;
var foc;
var b_con = "",b_flag=true;
var CurrentWinisActive=false;

window.onfocus = function() {
  CurrentWinisActive = true;
  if(b_flag==false){
  oPopup.show(screen.width-265,screen.height,241,178);
  }
}

window.onblur = function() {
  CurrentWinisActive = false;
  if(b_flag==false){
  oPopup.show(screen.width-265,screen.height,241,178);
  }
}


function set_content(content){
  var winstr="<table style=\"border: 1 solid #03A8F6;font-size:12px; background:#cfdef4;\" width=\"241px\" height=\"172px\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" >";
  winstr+="<tr><td height=\"30\" style=\" border-bottom:1px solid #03A8F6;color: red;\">&nbsp;新消息</td>";
  winstr+="<td align=\"right\" style=\" border-bottom:1px solid #03A8F6;\"><span id=close onclick=\"parent.close();\" style=\"cursor:pointer;\">[关闭]</span>&nbsp;</td>";
  winstr+="</tr><tr><td colspan=\"2\" style=\"padding:5px 0 0 5px;\" align=\"left\"><div style=\"overflow-y:auto; height:140px;\">"+content+"<div></td></tr>";
  winstr+="<tr><td colspan=\"2\" style=\"display:none;\">";
  winstr+="<object id=\"Player\" width=\"0px\" height=\"0px\" type=\"application/x-oleobject\" border=\"0\" classid=\"CLSid:6BF52A52-394A-11d3-B153-00C04F79FAA6\">";
  winstr+="<param name=\"URL\" value=\"/images/system.mp3\" /><param name=\"AutoStart\" value=\"true\" hidden=\"true\" /></OBJECT>";
  winstr+="</td></tr>"
  winstr+="</table>";
  return winstr;
}
function popmsg(content){
  b_flag = false;
oPopup.document.body.innerHTML = set_content(content);
popshow();
}
function popshow(){  
window.status="您有新消息(提示15秒后自动关闭)";

  if(popTop<180){
  popTop+=10;
  oPopup.show(screen.width-265,screen.height,241,popTop);
  }
  else{
clearTimeout(mytime);
focusWin();
window.status="";
return;
  }  
  var mytime=setTimeout("popshow();",50);
}
function close(){
  b_flag=true;
  popTop = 180;
  clearTimeout(foc);
  pophide();
}
function pophide(){
  if(popTop>0){
  popTop-=10;
  oPopup.show(screen.width-265,screen.height,241,popTop);
  }
  else{
clearTimeout(mytime);
oPopup.hide();
return;
  }
  var mytime=setTimeout("pophide();",50);
}
function focusWin()
{
  if(CurrentWinisActive==true){
  oPopup.show(screen.width-265,screen.height,241,178);
foc = setTimeout("focusWin();",50);
  }
}

if(!GetMessageCount){
  var GetMessageCount = {};
}

$(document).ready(
  function(){
  GetMessageCount.FindMessage();
  }
);
GetMessageCount.FindMessage = function(){
var msgtype=$("#msgtype").val();
  $.ajax({


  //处理ajax请求
  url:'/Admin/DataInfoM/FindNewMessage.ashx',
  data: 'msgtype=' + msgtype, //需要验证的参数 
  cache: false,
  //回调函数返回未读短信数目
  success: function(response)
  {
  //$('#messageCount').html(response);
  var content=response;
  if(content!=b_con&&content!=""&&content!=null&&content!="0"){
  b_con = content;
  if(!b_flag){
  oPopup.document.body.innerHTML = set_content(content);
  }
  else
  popmsg(content);
  }
  },
  error:function(data)
  {
  alert("加载失败");
  }
  });
  //每隔15秒递归调用一次,刷新未读短信数目
  window.setTimeout(GetMessageCount.FindMessage,15000);//核心语句
}
//------GetMessageCount.js End----------------------





[解决办法]
用div 模拟弹出窗口。
window.status
 很多浏览器,默认不允许状态栏被修改

热点排行
Bad Request.