Javascript showModalDialog() Function
In Web application we can use window.showMadalDialog() to popup a modal window. Now let's take a deep look at how to use this function.
1. Syntax
var vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures]);
parameters description:
sURL - required. data type : string. It refer to the URL of target ducument to link to.
vArguments - optional. data type : variant. It can be an object, an array. It is used to pass value to the target document. Using window.dialogArguments to retrieve the value passed in by this parameter.
sFeatures - optional. data type : string. It is used to setup look & feel of the dialog,such as height,width, show address bar or not, show status bar or not,resizable or not,etc. properties separate by semicolon(;).
2. Sample Code
1) Popup Modal Window Without Arguments
showModalWindow(url, '_blank',600,240, 'left=150,top=150,toolbar=no,menubar=no,scrollbars=no,location=no,resizable=no,status=no');
2) Popup Modal Window With Arguments
in the parent page:
var argObject = new Object();
argObject.username = 'eric';
argObject.age = '30';
var retValue = window.showModalDialog('myTargetPage.aspx', argObject, 'dialogWidth=400px;dialogHeight=150px;left=150,top=150,toolbar=no,menubar=no,scrollbars=no,location=no,resizable=no,status=no');
// do something else after got the return value from Modal Dialog here
and in the modal dialog:
var argObject = window.dialogArguments;// do something here....
window.returnValue = "return from modal dialog";window.self.close();
3) a modal window works for both IE and Firefox
function showModalWindow(url,name,width,height,decorate) {
if (window.showModalDialog) {
window.showModalDialog(url, window, 'dialogWidth=' + width + 'px;dialogHeight=' + height + 'px;' + decorate);
}
else {
window.open(url,name,'width=' + width + ',height=' + height + ',' + decorate + ',modal=yes');
}
}
3. showModalDialog Function will Load Page Cache
You may have noticed that when you have data changed for the modal window, then reopen the modal window, the page did not update. This is because that when you call showModalDialog(), IE will load the page cache and did not refresh the page content. To avoid this issue, Please do any of the alternatives below.
add this code line inside Page_Load()
this.Page.Response.Expires = 0;
or
Context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
4. Reference link
[@more@]來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/13651903/viewspace-1036689/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- JavaScript FunctionJavaScriptFunction
- javascript 中function(){},new function(),new Function(),Function 摘錄JavaScriptFunction
- JavaScript Function物件JavaScriptFunction物件
- JavaScript function 函式JavaScriptFunction函式
- JavaScript中的 FunctionJavaScriptFunction
- [Javascript] Why need arrow function?JavaScriptFunction
- JavaScript中的Date,RegExp,Function物件JavaScriptFunction物件
- JavaScript Promise Time Limit Function All In OneJavaScriptPromiseMITFunction
- JavaScript入門-函式function(二)JavaScript函式Function
- 使用原生javascript實現jquery的$(function(){ })JavaScriptjQueryFunction
- JavaScript中的函式過載(Function overloading)JavaScript函式Function
- JavaScript 高階函式(Heigher-order function)JavaScript函式Function
- 新人必看的短小而精悍的javascript functionJavaScriptFunction
- JavaScript: window.onload = function() {} 裡面的函式不執行JavaScriptFunction函式
- JavaScript 基礎(二) – 建立 function 物件的方法, String物件, Array物件JavaScriptFunction物件
- [Javascript] Access private variable inside IIFE and mutate this through Object.prototype getter functionJavaScriptIDEObjectFunction
- 【JavaScript框架封裝】使用Prototype給Array,String,Function物件的方法擴充JavaScript框架封裝Function物件
- [Bash] functionFunction
- python FunctionPythonFunction
- Loss FunctionFunction
- java.util.function 中的 Function、Predicate、ConsumerJavaFunction
- 關於showModalDialog()對話方塊點選按鈕彈出新頁面的問題
- 使用JavaScript Function.prototype進行程式碼重構的一些例子JavaScriptFunction行程
- JavaScript 引擎和 Just-in-Time 編譯概念,Hot Function 的簡單介紹JavaScript編譯Function
- Function型別Function型別
- DMSQL WITH FUNCTION子句SQLFunction
- A.Calculating FunctionFunction
- Function pointers and callbacksFunction
- addEventListener("touchend", function ()_devFunction
- TypeError: stringWidth is not a functionErrorFunction
- flask 裝飾器 AssertionError: View function mapping is overwriting an existing endpoint functionFlaskErrorViewFunctionAPP
- (function($,window,document){.......})用法Function
- Function.prototype.callFunction
- Uncaught TypeError: i is not a functionErrorFunction
- python - function list generatorPythonFunction
- C++ function pointersC++Function
- [Vue] Use render functionVueFunction
- jasmine.any(Function)ASMFunction
- drools中使用functionFunction