六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 49|回复: 0

右下角弹出层

[复制链接]

升级  86%

11

主题

11

主题

11

主题

童生

Rank: 1

积分
43
 楼主| 发表于 2013-1-23 02:42:17 | 显示全部楼层 |阅读模式
html(主页面)代码:
<div id="rbbox">
  <a class="button" >关闭</a>
  <iframe id="iframeyxj" src="yxjiframe.html" frameborder="0" height="150" width="180" scrolling="no"></iframe>
</div>
********************************
html(弹出的框)代码:
<body>
   <table>
    <tr>
     <td> 系统消息:</td>
    </tr>
    <tr>
     <td></td>
     <td><span style="font-size: 13px;color: red;">你好!</span></td>
    </tr>
   </table> 
  </body>
********************************
js代码:
//每5秒请求一次服务器
window.onload=function(){
 window.setInterval("CheckIsNewSystemInfo()",5000);
}
function CheckIsNewSystemInfo()
{
 var sync=true;
 var req = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
 req.open('POST','yxjMessage.action?id=iop',sync);
 req.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');  
 req.send("");
 req.onReadyStateChange=function(){
  if(req.readyState==4){
   if(req.responseText.length>0){
    var obj=eval(req.responseText);  
    if(obj=="ok")
    {
     ifmessage(obj);
    }
   }
  }
 }
 
/*
 $.ajax({
  type:"POST",
  url:"yxjMessage.action",
  data:"name=lop",
  success:function(msg){
   alert(mag[0]);
   //ifmessage(msg[0]);
  }
 });
 */
}
function ifmessage(msg)
{
 showBox();
}
function showBox(o){
 
        if (o==undefined) o=document.getElementById("rbbox"); 
        o.style.height=150;
        if(o.style.display==="none")
        {
         o.style.display="block";
        }

function closeBox(){
   var rbbox = document.getElementById("rbbox");
         document.getElementById("rbbox").style.display="none";

*****************************************************
后台(webwork):
public String execute() throws Exception {
  PrintWriter pwriter = response.getWriter();
  response.setContentType("text/xml");  
  response.setHeader("Cache-Control", "no-cache");
  JSONArray json = new JSONArray();
  List list = new ArrayList();
  list.add("ok");
  pwriter.write(json.fromObject(list).toString());
  pwriter.flush();
  pwriter.close();
  return null;
 }
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表