javascript 關閉窗口,彈出新窗口並帶有確認關閉對話框解決辦法


    在很多人眼里,北京是一個物欲橫流的社會,生活節奏之快,讓你一絲都不能停下來,走在路上伴隨着人群急速往前涌,或許有些人都不知道要去哪、也不知道自己想要的是什么?在一個浮躁的社會里,多了一些浮躁的人,到處的尋找捷徑,腳踏實地已經跑得無影無蹤。
    公司里項目一個接一個的上線,上線后一個接一個的出現問題,或許是我們該反思的時候了,在時間、質量、成本三者需要平衡的時候,我們總是會在時間和成本上做考慮,上線之前的演示只是一個紙老虎,其實離使用的程度差的很遠,我們總會一開始把客戶的欲望調得很高,但是種種的問題終究會在上線之后暴露出來,讓客戶產生一種落差,要想再逆轉這種結局需要付出百倍的努力,每個人都是消防隊員,哪里需要救火就到哪里去,遠看形勢一片美好,近看火海一撥比一撥高。
    最近又調回公司做一個救火的項目,我主要負責在線報名部分,包括以下幾個內容:
    1、專業人士門票的索取
    2、企業展會的報名
    3、后台包括專業人士和企業展會的查詢、搜索和導出。
    功能上沒有什么技術難點,但是必須在3天內上線,回來之后就開始了苦逼的生活,建表、建實體、寫接口、數據庫操作類、業務操作類,一切在掌控中進行。其中的企業展會包括參會企業信息和參會人員兩部分,一個企業可能對應多個參會人員,經過考慮采用了以下布局模式:



     點擊繼續添加參會人員,彈出一個模式窗口,

     后台代碼:

            GCMS.Model.EntAttendPerson entAttendPerModel = new Model.EntAttendPerson();
            GCMS.CMS.EntAttendInfo entAttend = new CMS.EntAttendInfo();

            entAttendPerModel.Name = this.txtName.Value;

            if (!string.IsNullOrEmpty(Request.Form["Sex"]))
                entAttendPerModel.Sex = int.Parse(Request.Form["Sex"]);

            entAttendPerModel.Job = this.txtJob.Value;
            entAttendPerModel.Telphone = this.txtTelphone.Value;
            entAttendPerModel.Mobile = this.txtMobile.Value;
            entAttendPerModel.Email = this.txtEmail.Value;

            if (!string.IsNullOrEmpty(Request.Form["radAccomRequire"]))
                entAttendPerModel.AccomRequire = int.Parse(Request.Form["radAccomRequire"]);

            if (!string.IsNullOrEmpty(Request.Form["txtAccomDateStart"]))
                entAttendPerModel.AccomDateStart = DateTime.Parse(this.txtAccomDateStart.Value);

            if (!string.IsNullOrEmpty(Request.Form["txtAccomDateEnd"]))
                entAttendPerModel.AccomDateEnd = DateTime.Parse(this.txtAccomDateEnd.Value);
            entAttendPerModel.EntAttendNum = this.hidGuid.Value;


            int count = 0;
            if (string.IsNullOrEmpty(Request.QueryString["id"]))
                count = entAttend.AddEntAttendPer(entAttendPerModel);
            else
            {
                entAttendPerModel.Id = int.Parse(Request.QueryString["id"]);
                count = entAttend.UpdateEntAttendPer(entAttendPerModel);
            }
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), String.Empty, "addEntAttendPerTip(" + count + ");", true);

     前台js:

    <head runat="server">
    <title>中國智慧城市大會_在線報名</title>
    <base target="_self" />
     <script type="text/javascript">
        window.onload = function a() {
            //取得傳入參數
            var argu = window.dialogArguments;
            if (argu) {
                if (argu.guid != "") {
                    document.getElementById("hidGuid").value = argu.guid;
                }
            }
        }
        function addEntAttendPerTip(addCount) {
            if (addCount > 0) {
                alert("操作成功!");
                var result = new Object();
                result.IsAdd = addCount;
                window.returnValue = result;
                 window.close();
            }
            else {
                alert("操作失敗!");
            }
        }
   <script>

     添加完成以后,刷新下面的列表。並可對列表中的參會人員進行編輯和刪除。
     在臨近上線的時候,突然出現了一個問題,當在添加完參會人員關閉模式窗口的時候,”奇跡“出現了,在關閉的時候彈出了一個新的頁面提示操作成功,並伴有是否關閉窗口的提示框,火狐中並不會出現問題,IE中會出現此問題,在勝利到來的時候,老天總會和你開一些玩笑,兵來將擋水來土掩,查找資料,原因就在於點擊添加的時候,出現了一個新窗口而不是在原有的窗口上面完成添加操作,最后在在添加參會人員的模式窗體 head 中添加 <base target="_self" />,讓頁面自己去處理請求,問題迎刃而解。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM