1.JavaScript的模態窗口在開發中經常用到.
父窗口中打開模態窗口:
var chkStr=showModalDialog("page.aspx","", "dialogWidth:400px; dialogLeft:5px; dialogHeight:200px;status:0; help:0;");
子窗口中返回:
window.returnValue= strReturnValue ; window.close();
模態窗口返回類型主要是:null,undefined,還有你的ReturnValue值類型
2.showModalDialog和showModallessDialog的區別了:
同:兩者彈出的窗體不能刷新 異:前者是模態窗口,始終獲得焦點;後者是非模態窗口,只不過彈出一個頁面,還可以操作父窗口.如:
<SCRIPT>
function fnRandom(iModifier){
return parseInt(Math.random()*iModifier);
}
function fnSetValues(){
var iHeight=oForm.oHeight.options[
oForm.oHeight.selectedIndex].text;
if(iHeight.indexOf("Random")>-1){
iHeight=fnRandom(document.body.clientHeight);
}
var sFeatures="dialogHeight: " + iHeight + "px;";
return sFeatures;
}
function fnOpen(){
var sFeatures=fnSetValues();
window.showModalDialog("1.htm", "",//showModalDialog_target
sFeatures)
}
</SCRIPT>
<FORM NAME=oForm>
Dialog Height <SELECT NAME="oHeight">
<OPTION>-- Random --
<OPTION>150
<OPTION>200
<OPTION>250
<OPTION>300
</SELECT>
Create Modal Dialog Box
<INPUT TYPE="button" VALUE="click To Create"
οnclick="fnOpen()">
</FORM>
還有就是IE7.0中會顯示模態窗口真實路徑的問題.這個是IE7.0安全考慮,目前沒有辦法解決.可以用層來模擬模態窗口