easyui的window学习

目的:弹出、关闭window。
效果图:

window效果图

代码:/EasyUiLearn/WebContent/window/index.jsp

<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath();%>
<%String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <base href="<%=basePath %>">
    <title>window</title>
    <!--
    <link rel="stylesheet" type="text/css" href="jquery-easyui-1.4.3/themes/default/easyui.css">
    --> 
    <link rel="stylesheet" type="text/css" href="jquery-easyui-1.4.3/themes/bootstrap/easyui.css">
     
    <link rel="stylesheet" type="text/css" href="jquery-easyui-1.4.3/themes/icon.css">
    <script type="text/javascript" src="jquery-easyui-1.4.3/jquery.min.js"></script>
    <script type="text/javascript" src="jquery-easyui-1.4.3/jquery.easyui.min.js"></script>
</head>
<script>
var windowMain = {
    initWindow:function(){
        $("#win").window({
            title:"一个弹出窗口",
            width:600,
            height:400,
            modal:true,
            closed:true,
            href:"window/window.jsp",
            onLoad:function(){
                console.log('页面加载完成调用!');
                //为新加载的页面控件绑定事件
                $("#closeBtn").click(function(){
                    $("#win").window("close");
                });
            }
        });
    }
}
$(function(){
    windowMain.initWindow();
});

function openWin(){
    $("#win").window("open");
}
</script>
<body>
<a href="javascript:void(0);" class="easyui-linkbutton" onClick="javascript:openWin();">打开</a><br><br>
<div id="win"></div>
</body>
</html>

window代码:/EasyUiLearn/WebContent/window/window.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<div class="easyui-panel" style="padding:10px;">
    <form id="ff" action="form1_proc.php" method="post" enctype="multipart/form-data">
        <table>
            <tr>
                <td>Name:</td>
                <td><input name="name" class="f1 easyui-textbox"></input></td>
            </tr>
            <tr>
                <td>Email:</td>
                <td><input name="email" class="f1 easyui-textbox"></input></td>
            </tr>
            <tr>
                <td>Phone:</td>
                <td><input name="phone" class="f1 easyui-textbox"></input></td>
            </tr>
            <tr>
                <td>File:</td>
                <td><input name="file" class="f1 easyui-filebox"></input></td>
            </tr>
            <tr>
                <td><a id="closeBtn" class="easyui-linkbutton" href="javascript:void(0)">关闭</a></td>
                <td></td>
            </tr>
        </table>
    </form>
</div>

要点:

  1. 页面添加window div。
    <div id="win"></div>
  2. window初始化。
    $("#win").window({})
    页面就在完成后调用window初始化。windowMain.initWindow();
  3. window加载完成调用onLoad,在这个方法中给window.jsp页面的控件绑定事件。
  4. 打开window。$("#win").window("open");
  5. 关闭window。$("#win").window("close");

源码下载

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1. Java基础部分 基础部分的顺序:基本语法,类相关的语法,内部类的语法,继承相关的语法,异常的语法,线程的语...
    子非鱼_t_阅读 33,377评论 18 399
  • 一. Java基础部分.................................................
    wy_sure阅读 9,296评论 0 11
  • <a name='html'>HTML</a> Doctype作用?标准模式与兼容模式各有什么区别? (1)、<...
    clark124阅读 9,028评论 1 19
  • 仅以此纪念我挫的不得了的算法 这是我的第一篇简书,在线笔试,感觉叫做鄙视更恰当,因为真心觉得自己的算法烂到不行了。...
    dooze阅读 2,405评论 3 0
  • 如果没有记错,第一次看《返老还童》也是三年前的事情了,那一年,是你先看的,看完之后给我打电话说“晚安,毛毛”。...
    这天气很晴朗阅读 1,715评论 0 1

友情链接更多精彩内容