Dialog query

本文介绍如何利用jQuery和HTML创建一个动态加载内容的模态框。通过在页面上定义一个空的div作为模态框容器,并使用按钮触发,可以打开包含用户基本信息的模态对话框。模态框中的内容通过iframe从服务器动态加载。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 1.在页面中引入:

<script type="text/javascript" src="<%=contextPath%>/js/jquery-ui.min.js"></script>
<link type="text/css" href="<%=contextPath%>/css/jquery-ui.css" rel="stylesheet" />

2.在页面中加入层

<div id="dialog-modal" title="用户基本信息查看" ></div> 

3.添加一个按钮

<button id="name" onclick="opens('<s:property value="message.user.userid" />')">查 看</button>

4.写对应的opens方法

 

function opens(userid){
  var url="<%=contextPath%>/user/lookUser.action?usertable.userid="+userid;
   $('#dialog-modal').html('<iframe width="100%" height="100%" name="dialog-modal-iframe" src="'+url+'"  scrolling="no" frameborder="0" ></iframe>');
     $('#dialog-modal').dialog('open');
   }

 

5.dialog设置

$(function(){

 $("#dialog-modal").dialog({
             buttons: {  
                 "关闭": function(){  
                  //addIframeData();
                  $("#dialog-modal").dialog("close");
                  }
               } ,
       stackfix: true,
          autoOpen: false,
                width: 600,
                height: 650,
                position: 'middle',
               modal: true         //true:模态, false:非模态
    });

})

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值