window.open('Default2.aspx','信息窗口','height=480,   width=405,   top=0,left=225,toolbar=no,menubar=no,scrollbars=yes,alwaysRaised=yes,   resizable=no,location=no,status=no,dependent=yes')
现在我想打开一个窗口,该窗口要像模式窗口一样,这个窗口不关闭,无法点击父窗体上的内容,窗口要居中显示。请教各位我上面写的代码错在哪里

解决方案 »

  1.   

    var top = (window.screen.height -height)/2;
    var left =  (window.screen.width-width)/2;
    居中显示
      

  2.   

    写过个JS函数。给LZ参考下。/*
    Winopen 使用说明:弹出页必须加<base target="_self">,否则提交时会弹出新窗口
    最好也加入:
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    否则页面被缓存会造成更改页面后不能显示为最新的
    Parameter详解:
    1.   dialogHeight:   对话框高度,不小于100px
    2.   dialogWidth:   对话框宽度。
    3.   dialogLeft:    离屏幕左的距离。
    4.   dialogTop:    离屏幕上的距离。
    5.   center:  { yes | no | 1 | 0 } : 是否居中,默认yes,但仍可以指定高度和宽度。
    6.   help: {yes | no | 1 | 0 }:      是否显示帮助按钮,默认yes。
    7.   resizable:  {yes | no | 1 | 0 } [IE5+]:    是否可被改变大小。默认no。
    8.   status:{yes | no | 1 | 0 } [IE5+]:是否显示状态栏。默认为yes[ Modeless]或no[Modal]。
    9.   scroll:{ yes | no | 1 | 0 | on | off }:是否显示滚动条。默认为yes。
    示例:WinOpen('test.html','test','dialogHeight:300px;dialogWidth:200px;help:no;status:no;')
    */
    function Winopen(PageUrl,title,parameter)
    {
    var sRet = window.showModalDialog(PageUrl,title,parameter);
    if(sRet == "refresh")
    {window.location.reload();}
    }
      

  3.   

    居中(相对于屏幕,而不是父窗口)  var left = (screen.width-405)/2;
      var top = (screen.height -480)/2;
      window.open('Default2.aspx','信息窗口','height=480,width=405,top='+ top +', left='+left+', toolbar=no,menubar=no,scrollbars=yes,alwaysRaised=yes,   resizable=no,location=no,status=no,dependent=yes')
      

  4.   

    showModalDialog 是可以的,但仅限于IE .
      

  5.   

    你用div实现一个弹出窗口效果,这些问题不就都好解决了吗,仅仅是建议。
      

  6.   

    各位好,showModalDialog 在我项目的框架中无效,所以只能用window.open();
      

  7.   


    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script language="javascript">
    /*
        Winopen 使用说明:弹出页必须加<base target="_self">,否则提交时会弹出新窗口
        最好也加入:
        <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
        <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
        <META HTTP-EQUIV="Expires" CONTENT="0">
        否则页面被缓存会造成更改页面后不能显示为最新的
        Parameter详解:
        1.   dialogHeight:   对话框高度,不小于100px
        2.   dialogWidth:   对话框宽度。
        3.   dialogLeft:    离屏幕左的距离。
        4.   dialogTop:    离屏幕上的距离。
        5.   center:  { yes | no | 1 | 0 } : 是否居中,默认yes,但仍可以指定高度和宽度。
        6.   help: {yes | no | 1 | 0 }:      是否显示帮助按钮,默认yes。
        7.   resizable:  {yes | no | 1 | 0 } [IE5+]:    是否可被改变大小。默认no。
        8.   status:{yes | no | 1 | 0 } [IE5+]:是否显示状态栏。默认为yes[ Modeless]或no[Modal]。
        9.   scroll:{ yes | no | 1 | 0 | on | off }:是否显示滚动条。默认为yes。
        示例:WinOpen('test.html','test','dialogHeight:300px;dialogWidth:200px;help:no;status:no;')
    */
    function Winopen(PageUrl,title,parameter)
        {
            var sRet = window.showModalDialog(PageUrl,title,parameter);
            if(sRet == "refresh")
            {window.location.reload();}
        }</script>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head><body><input type="button" onclick="Winopen('http://www.baidu.com','title','dialogHeight:500px;dialogWidth:450px;edge:Raised;status:no;scroll:Yes;');" value="test" /></body>
    </html>测试没问题。
    LZ不考虑我的代码么。。我一直是用这个的。。
      

  8.   


    哥们。我这里不能用showModalDialog。。
      

  9.   

    在页面上添加一个DIV,初始dispaly设为none,里面加上一个<iframe src="Default2.aspx" height="400" width="300">,需要弹出页面的时候让display='block'就行了
      

  10.   

    补充下……
    div的样式
    .d{
       position:absolute;
       z-index:3;
       top:0px;
       left:0px;
       width:300px;
       height:400px;
    }