自己項目中,幾種打開或彈出頁面的方法(部分需要特定環境下)

var blnTop = false;//是否在頂層顯示 ///動態生成模態窗體(通過字符串生成) ///strModalId:模態窗體ID ///strTitle:模態窗體標題 ///strContent:模態窗體html字符串內容 ///strFooter:模態窗體右下方html字符串內容 ///intWidth:模態窗體的寬度 ///intHeight:模態窗體的高度 var ModeDialogContent = function (strModalId, strTitle, strContent, strFooter, intWidth, intHeight) { if (strModalId == null || strModalId == '') { abp.message.error("請指定對話框ID", "消息提示"); return; } var strStyle = ""; if (intWidth != null && intWidth != "") strStyle = "width:" + intWidth + "px;"; if (intHeight != null && intHeight != "") strStyle += "height:" + intHeight + "px"; if (strStyle != "") strStyle = " style='" + strStyle + "'"; var strModalHtml = "<div class='modal fade' id='" + strModalId + "' tabindex='-1' aria-hidden='true' data-backdrop='static' role='dialog' aria-hidden='true'>"; strModalHtml += "<div class='modal-dialog' " + strStyle + ">"; strModalHtml += "<div class='modal-content' " + strStyle + ">"; strModalHtml += "<div class='modal-header'>"; strModalHtml += "<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>"; strModalHtml += "<h4 class='modal-title' >" + strTitle + "</h4></div>"; strModalHtml += "<div class='modal-body'>" + strContent + "</div>"; strModalHtml += "<div class='modal-footer'>"; strModalHtml += strFooter; strModalHtml += "<button type='button' class='btn btn-danger' data-dismiss='modal'><i class='fa fa-times'></i> 關閉</button>"; strModalHtml += "</div>"; strModalHtml += "</div>"; strModalHtml += "</div>"; strModalHtml += "</div>"; var objHtml = $(strModalHtml); objHtml.find(".modal-body").height($(strModalHtml).find(".modal-content").height() - 75);//設置URL地址的高度 //是否在頂層顯示 if (blnTop) { $(strModalHtml).appendTo(window.top.$("body")); window.top.$("#" + strModalId).modal("show"); } else { $(strModalHtml).appendTo(this.$("body")); $("#" + strModalId).modal("show"); } } ///動態生成模態窗體頂層顯示 ///strModalId:模態窗體ID ///strTitle:模態窗體標題 ///strContent:模態窗體html字符串內容 ///strFooter:模態窗體右下方html字符串內容 ///intWidth:模態窗體的寬度 ///intHeight:模態窗體的高度 var TopModeDialogContent = function (strModalId, strTitle, strContent, strFooter, intWidth, intHeight) { blnTop = true;//頂層顯示 ModeDialogContent(strModalId, strTitle, strContent, strFooter, intWidth, intHeight); blnTop = false;//修改成默認值 } ///動態生成模態窗體(通過對像生成) ///strModalId:模態窗體ID ///strTitle:模態窗體標題 ///strContent:模態窗體對像內容 ///strFooter:模態窗體右下角對像內容 ///intWidth:模態窗體的寬度 ///intHeight:模態窗體的高度 var ModeDialogObjContent = function (strModalId, strTitle, objContent, objFooter, intWidth, intHeight) { if (strModalId == null || strModalId == '') { abp.message.error("請指定對話框ID", "消息提示"); return; } var strStyle = ""; if (intWidth != null && intWidth != "") strStyle = "width:" + intWidth + "px;"; if (intHeight != null && intHeight != "") strStyle += "height:" + intHeight + "px"; if (strStyle != "") strStyle = " style='" + strStyle + "'"; var strModalHtml = "<div class='modal fade' id='" + strModalId + "' tabindex='-1' aria-hidden='true' data-backdrop='static' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>"; strModalHtml += "<div class='modal-dialog' " + strStyle + ">"; strModalHtml += "<div class='modal-content' " + strStyle + ">"; strModalHtml += "<div class='modal-header'>"; strModalHtml += "<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>"; strModalHtml += "<h4 class='modal-title'>" + strTitle + "</h4></div>"; strModalHtml += "<div class='modal-body'></div>"; strModalHtml += "<div class='modal-footer'>"; strModalHtml += "<button type='button' class='btn btn-default' data-dismiss='modal'><i class='fa fa-times'></i> 關閉</button>"; strModalHtml += "</div>"; strModalHtml += "</div>"; strModalHtml += "</div>"; strModalHtml += "</div>"; var objHtml = $(strModalHtml); objHtml.find(".modal-body").append(objContent); objHtml.find(".modal-footer").append(objFooter); objHtml.find(".modal-body").height($(strModalHtml).find(".modal-content").height() - 75);//設置URL地址的高度 //是否在頂層顯示 if (blnTop) { $(objHtml).appendTo(window.top.$("body")); window.top.$("#" + strModalId).modal("show"); } else { $(objHtml).appendTo(this.$("body")); $("#" + strModalId).modal("show"); } } ///動態生成模態窗體頂層顯示(通過對像生成) ///strModalId:模態窗體ID ///strTitle:模態窗體標題 ///strContent:模態窗體對像內容 ///strFooter:模態窗體右下角對像內容 ///intWidth:模態窗體的寬度 ///intHeight:模態窗體的高度 var TopModeDialogObjContent = function (strModalId, strTitle, objContent, objFooter, intWidth, intHeight) { blnTop = true; ModeDialogObjContent(strModalId, strTitle, objContent, objFooter, intWidth, intHeight); blnTop = false; } ///動態生成模態窗體(通過URL生成) ///strModalId:模態窗體ID ///strTitle:模態窗體標題 ///strUrl:模態窗體URL ///intWidth:模態窗體的寬度 ///intHeight:模態窗體的高度 var ModeDialogUrl = function (strModalId, strTitle, strUrl, intWidth, intHeight) { if (strUrl == null || strUrl == '') { abp.message.error("無連接地址", "消息提示"); return; } strUrl = GetPath(strUrl);//標准化地址 var strStyle = ""; if (intWidth != null && intWidth != "") strStyle = "width:" + intWidth + "px;"; if (intHeight != null && intHeight != "") strStyle += "height:" + intHeight + "px"; if (strStyle != "") strStyle = " style='" + strStyle + "'"; var strModalHtml = "<div class='modal fade' id='" + strModalId + "' tabindex='-1' role='dialog' aria-hidden='true' aria-hidden='true' data-backdrop='static'>"; strModalHtml += "<div class='modal-dialog' " + strStyle + ">"; strModalHtml += "<div class='modal-content' " + strStyle + ">"; strModalHtml += "<div class='modal-header'>"; strModalHtml += "<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>"; strModalHtml += "<h4 class='modal-title' >" + strTitle + "</h4></div>"; strModalHtml += "<div class='modal-body' style='width:100%;'><iframe style='width:100%;height:100%' frameborder='0' scrolling='auto' src='" + strUrl + "'></iframe></div>"; strModalHtml += "</div>"; strModalHtml += "</div>"; strModalHtml += "</div>"; var objHtml = $(strModalHtml); objHtml.find(".modal-body").height($(strModalHtml).find(".modal-content").height() - 75);//設置URL地址的高度 //是否在頂層顯示 if (blnTop) { objHtml.appendTo(window.top.$("html")); window.top.$("#" + strModalId).modal("show"); } else { objHtml.appendTo(this.$("html")); $("#" + strModalId).modal("show"); } } ///動態生成模態窗體頂層顯示(通過對像生成) ///strModalId:模態窗體ID ///strTitle:模態窗體標題 ///strUrl:模態窗體URL ///intWidth:模態窗體的寬度 ///intHeight:模態窗體的高度 var TopModeDialogUrl = function (strModalId, strTitle, strUrl, intWidth, intHeight) { blnTop = true; ModeDialogUrl(strModalId, strTitle, strUrl, intWidth, intHeight); blnTop = false; } ///模式窗口彈出(指定大小) ///strTitle:窗體標題 ///strUrl:內容顯示地址 ///intWidth:窗體寬度 ///intHeight:窗休息高度 var ModelDialog = function (strTitle, strUrl, intWidth, intHeight) { if (strUrl == null || strUrl == '') { abp.message.error("無連接地址", "消息提示"); return; } strUrl = GetPath(strUrl);//標准化地址 DiyModal.window({ title: strTitle, url: strUrl, width: intWidth, height: intHeight, fullscreen: false ////afterClose: function () { //// table.reload(); ////} }).open(); }; ///模式窗口彈出(全屏展示) ///strTitle:窗體標題 ///strUrl:內容顯示地址 var FullModelDialog = function (strTitle, strUrl) { ModelDialog(strTitle, strUrl, (window.innerWidth * 0.96), (window.innerHeight * 0.96)); }; var blnSon = false;//是否子窗口打開 ///瀏覽器彈出窗口 ///strTitle:窗體標題 ///strUrl:內容顯示地址 ///intWidth:窗體寬度 ///intHeight:窗休息高度 var WindowOpen = function (strTitle, strUrl, intWidth, intHeight) { if (strUrl == null || strUrl == '') { abp.message.error("無連接地址", "消息提示"); return; } strUrl = GetPath(strUrl);//標准化地址 if (strTitle == null || strTitle == '') { strTitle = ''; } if (intWidth == null || intWidth == '') { intWidth = 0; } if (intHeight == null || intHeight == '') { intHeight = 0; } if (intWidth == 0 || intHeight == 0) { window.open(strUrl, strTitle, (blnSon ? 'fullscreen=0,' : '') + 'height=' + screen.height + ', width=' + screen.width + ', top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no') } else { window.open(strUrl, strTitle, (blnSon ? 'fullscreen=0,' : '') + 'height=' + intHeight + ', width=' + intWidth + ', top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no') } }; ///瀏覽器彈出窗口 ///strTitle:窗體標題 ///strUrl:內容顯示地址 ///intWidth:窗體寬度 ///intHeight:窗休息高度 var WindowSonOpen = function (strTitle, strUrl, intWidth, intHeight) { blnSon = true; WindowOpen(strTitle, strUrl, intWidth, intHeight); blnSon = false; }; ///當前瀏覽器原地址跳轉 ///strUrl:內容顯示地址 var WindowLocation = function (strUrl) { if (strUrl == null || strUrl == '') { abp.message.error("無連接地址", "消息提示"); return; } strUrl = GetPath(strUrl);//標准化地址 window.location.href = strUrl; }; ///當前瀏覽器頂級窗口地址跳轉 ///strUrl:內容顯示地址 var WindowTopLocation = function (strUrl) { if (strUrl == null || strUrl == '') { abp.message.error("無連接地址", "消息提示"); return; } strUrl = GetPath(strUrl);//標准化地址 window.top.location.href = strUrl; }; ///當前瀏覽器父級窗口地址跳轉 ///strUrl:內容顯示地址 var WindowParentLocation = function (strUrl) { if (strUrl == null || strUrl == '') { abp.message.error("無連接地址", "消息提示"); return; } strUrl = GetPath(strUrl);//標准化地址 window.parent.location.href = strUrl; }; ///當前瀏覽器指定框架地址重定向 ///strUrl:內容顯示地址 ///strFrame:是重定向的框架名稱 var WindowFramesLocation = function (strFrame, strUrl) { if (strUrl == null || strUrl == '') { abp.message.error("無連接地址", "消息提示"); return; } strUrl = GetPath(strUrl);//標准化地址 if (strFrame == null || strFrame == '') { abp.message.error("框架名稱為空", "消息提示"); return; } if (window.parent.iframeName != null) {//查找父級IFRAME window.parent.iframeName.location.href = strUrl; } else if (window.parent.frames[strFrame] != null) { //查找父級下面的IFRAME window.parent.frames[strFrame].location.href = strUrl; } else if (window.frames[strFrame] != null) {//查找下級的IFAME window.frames[strFrame].location.href = strUrl; } else { abp.message.error("找不到您所指定的框架名", "消息提示"); } }; ///添加選項卡 ///strUrl:選項卡URL地址 ///strName:選項卡名稱 var AddTab = function (strName, strUrl) { if (strUrl == undefined || $.trim(strUrl).length == 0 || strName == undefined || $.trim(strName).length == 0) { abp.message.error("地址及選項卡名稱不能為空", "消息提示"); return false; } strUrl = GetPath(strUrl);//標准化地址 var strIframe = "iframe" + Math.floor(Math.random() * 101);//自動生成iframe框架名稱及ID var flag = true;//是否存在此選項卡 //查詢選項卡中是否已存在了要添加的選項卡,如果存在了,就選中處理 window.parent.$('.menuTab').each(function () { if ($(this).data('id') == strUrl) { if (!$(this).hasClass('active')) { $(this).addClass('active').siblings('.menuTab').removeClass('active'); $.learuntab.scrollToTab(this); window.parent.$('.mainContent .LRADMS_iframe').each(function () { if ($(this).data('id') == strUrl) { $(this).show().siblings('.LRADMS_iframe').hide(); return false; } }); } flag = false; return false; } }); //添加選項卡 if (flag) { var str = '<a href="javascript:;" class="active menuTab" data-id="' + strUrl + '">' + strName + ' <i class="fa fa-remove"></i></a>'; window.parent.$('.menuTab').removeClass('active'); var str1 = '<iframe class="LRADMS_iframe" id="' + strIframe + '" name="' + strIframe + '" width="100%" height="100%" src="' + strUrl + '" frameborder="0" data-id="' + strUrl + '" seamless></iframe>'; window.parent.$('.mainContent').find('iframe.LRADMS_iframe').hide(); window.parent.$('.mainContent').append(str1); window.parent.$('.menuTabs .page-tabs-content').append(str); $.learuntab.scrollToTab($('.menuTab.active')); } }; ///AJAX請求 ///strUrl:請求URL ///btnObj:請求按鈕對像 var AjaxFun = function (strUrl, btnObj) { var paramData = "{'" + GetParamJson(strUrl) + "'}"; var btnName = btnObj.innerText; var strUrl = GetPath(strUrl); $.ajax({ url: strUrl, type: 'POST', dataType: 'JSON', data: paramData, success: function (result) { if (result != null) { abp.message.success("", btnName + "成功!"); } }, complete: function (XMLHttpRequest, status) { //請求完成后最終執行參數 if (status != 'success') { abp.message.error("狀態為:" + status, btnName + "請求有誤!"); } } }); };