Web开发中的对话框弹出方式

1、原始的弹出对话框实现(弹出窗口也可以)

我们知道,以前在没有应用其他javascript库(例如各种类型的Jquery库)的时候,一般是通过window.open或者window.showModalDialog来弹出非模态或者模态的对话框的,如下脚本所示。

function OpenWin( sURL , sFeatures )
{
window.open( sURL , null , sFeatures , null)
//window.open("Sample.htm",null,"height=200,width=400,status=yes,toolbar=no,menubar=no,location=no");
//window.open( [sURL] [, sName] [, sFeatures] [, bReplace])
//sName{_blank; _media; _parent; _search; _self; _top}
//sFeatures{channelmode; directories; fullscreen; height; left; location; menubar; resizable; scrollbars; status; titlebar; toolbar; top; width}
}

function ShowWin( sURL , sFeatures )
{
if(sFeatures == null || sFeatures == ""){
sFeatures = 'dialogHeight:300px;dialogWidth:850px;status:no;scroll:yes;resizable:yes;help:no;center:yes;';
}

var returnValue= window.showModalDialog( sURL , null , sFeatures)
//window.showModalDialog("Sample.htm",null,"dialogHeight:591px;dialogWidth:650px;")
//window.showModalDialog([sURL] [, vArguments] [, sFeatures])
//sFeatures{dialogHeight; dialogLeft; dialogTop; dialogWidth; center; dialogHide; edge; help; resizable; scroll; status; unadorned}
if(returnValue != undefined)
{
return returnValue;
}
else
{
return "";
}
}

这种是原始方式;大家经常都会用到。
原始方式第二种基于Jquery的原始弹出窗口方式:
<script type= "text/javascript">    

         function initDialog(divname) {    
                 var dlg = jQuery(divname).dialog({    
                        draggable: true,    
                        resizable: true,    
                        closed: true,    
                        show: 'Transfer',    
                        hide: 'Transfer',    
                        autoOpen: false,    
                        width: 500,    
                        height: 250,    
                        minHeight: 10,    
                        minwidth: 10    
                });    
                dlg.parent().appendTo(jQuery( "form:first"));    
        };    

         function close(divname) {    
                $(divname).dialog('close');    
        }    
        </script>

  (二)(待添加。。。) 

你可能感兴趣的:(JavaScript,jquery,function,对话框)