zoukankan      html  css  js  c++  java
  • thickbox提交数据后关闭子窗口刷新父窗口

    1.父页面添加引用 
    <script type="text/javascript" src="<web.path:path/>/js/jquery.js"></script>
    <script type="text/javascript" src="<web.path:path/>/js/thickbox.js"></script>
    <link rel="stylesheet" href="<web.path:path/>/resources/css/thickbox.css" type="text/css" media="screen" />

    2.父页面添加如下按钮,引用thickbox打开子窗口
    <input alt="<web.path:path/>/bannedUserList!unBannedUserList?height=400&width=800&inlineId=myOnPageContent" title="Ban Another Users" class="thickbox" type="button" value="Ban Another"/> 

    3.子页面添加按钮或链接
    <input id="banUser" type="button" value="Save"/> 
    <input id="closeBT" type="button" value="Cancel"/> 

    4.子页面添加相关jQuery和thickbox代码(因为父页面已经引用了jQuery和thickbox库,子页面不需要再引用)
    <SCRIPT type="text/javascript">
    $("#closeBT").click(function(){
        tb_remove();
    });

    //click the save button to submit, close the current window and refresh the opener window
    $("#banUser").click(function(){

        //get the transfer params
        var users = new Array();
        $("input:checkbox").each(function(){
            if(this.checked) {
                users.push($(this).val());
            }
        });
        
        $.ajax({
            type:"POST",
            url:"<web.path:path/>/bannedUserList!banUser",
            data:"users="+users.join(","),
            success:function(msg){
                tb_remove();    //close the thickbox
                var win = top.window; 
                try{ 
                    if(win){ 
                       win.location.reload();     //refresh the opener window
                    }
                }catch(ex){} 
            }
        });

    });
    </SCRIPT>

  • 相关阅读:
    课程设计之第二次冲刺----第一天
    第一个spring冲刺总结
    课程设计之第一次冲刺----第九天
    课程设计之第一次冲刺----第八天
    课程设计之第一次冲刺----第七天
    课程设计之第一次冲刺----第六天
    课程设计之第一次冲刺---第5天
    课程设计之第一次冲刺---第四天
    课程设计之第一次冲刺---第3天
    课程设计之第一次冲刺---第二天
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/1694047.html
Copyright © 2011-2022 走看看