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()JavaScriptFunction
- javascript 中function(){},new function(),new Function(),Function 摘錄JavaScriptFunction
- JavaScript Function物件JavaScriptFunction物件
- JavaScript function 函式JavaScriptFunction函式
- JavaScript中的 FunctionJavaScriptFunction
- [Javascript] Why need arrow function?JavaScriptFunction
- Javascript 物件導向學習1 Function function ObjectJavaScript物件FunctionObject
- javascript Function()建構函式JavaScriptFunction函式
- 【JavaScript】Function型別是物件JavaScriptFunction型別物件
- JavaScript入門-函式function(二)JavaScript函式Function
- javascript Function()使用程式碼例項JavaScriptFunction
- JavaScript Function 函式深入總結JavaScriptFunction函式
- JavaScript Promise Time Limit Function All In OneJavaScriptPromiseMITFunction
- 使用原生javascript實現jquery的$(function(){ })JavaScriptjQueryFunction
- javascript function的多種用法詳解JavaScriptFunction
- 理解 JavaScript 中的 Function.prototype.bindJavaScriptFunction
- 理解JavaScript中的Function.prototype.bindJavaScriptFunction
- Javascript之旅——第九站:吐槽functionJavaScriptFunction
- 新人必看的短小而精悍的javascript functionJavaScriptFunction
- JavaScript中的Date,RegExp,Function物件JavaScriptFunction物件
- JavaScript自執行函式(function(){})()的理解JavaScript函式Function
- javascript __proto___ prototype和Function原始碼狂想JavaScriptFunction原始碼
- showModalDialog()、showModelessDialog()方法使用詳解
- JavaScript 高階函式(Heigher-order function)JavaScript函式Function
- JavaScript學習總結(四)function函式部分JavaScriptFunction函式
- JavaScript中的函式過載(Function overloading)JavaScript函式Function
- javascript中的自執行(立即執行)函式(function(){…})()JavaScript函式Function
- JavaScript: window.onload = function() {} 裡面的函式不執行JavaScriptFunction函式
- js原型繼承與多型 How to apply virtual function in javascriptJS原型繼承多型APPFunctionJavaScript
- $(function(){})與(function($){....})(jQuery)的區別FunctionjQuery
- js為showModalDialog()彈出視窗的頁面傳值JS
- JavaScript 基礎(二) – 建立 function 物件的方法, String物件, Array物件JavaScriptFunction物件
- sendDataByUdp FunctionUDPFunction
- Substr FunctionFunction
- Function : dumpFunction
- [Bash] functionFunction
- [Javascript] Access private variable inside IIFE and mutate this through Object.prototype getter functionJavaScriptIDEObjectFunction