我是在.cs中这样写的Button1.Attributes.Add("onclick", "javascript:window.open('ProductsQuotationUpLoad.aspx?ProjectNo=" + ProjectNo + "&BaoJiaDanID=" + HDFBaoJiaDanID.Value + "&FileTypeID=44,45','new1','width=950,height=100,menubar=no,scrollbars=no, resizable=no,location=no,status=no,top=200,left=(screen.AvailWidth - 950) / 2')");
运行后HTML源码如下<input type="submit" name="GridView1$ctl02$Button1" value="文件上传" onclick="javascript:window.open('ProductsQuotationUpLoad.aspx?ProjectNo=B41193001&amp;BaoJiaDanID=B41193001-TSBJ20090908171709&amp;FileTypeID=44,45','new1','width=950,height=100,menubar=no,scrollbars=no, resizable=no,location=no,status=no,top=200,left=(screen.AvailWidth - 950) / 2');" id="GridView1_ctl02_Button1" />
为何弹出的页面还是不能居中显示呢?还是居左显示

解决方案 »

  1.   

    window.open('ProductsQuotationUpLoad.aspx?ProjectNo=" + ProjectNo + "&BaoJiaDanID=" + HDFBaoJiaDanID.Value + "&FileTypeID=44,45','new1','width=950,height=100,menubar=no,scrollbars=no, resizable=no,location=no,status=no,top=200,left=(screen.AvailWidth - 950) / 2')
    把它写在 一个函数里吧,然后在后台用Button注册这个脚本
      

  2.   

    function openwindow(url,sTitle,sSize)      
    {      
        if (url==''){
          return false;
        }    if (nwin && !nwin.closed){      
           nwin.close();      
        }      
          if (sSize == undefined) {
           alert("请指定窗口型号!");
           return false;
        }
        else if (sSize == 100) {
           sWidth  = screen.availWidth;
           sHeight = screen.availHeight;
        }   else if (sSize == 1) {
           sWidth  = 280;
           sHeight = 120;
        }
        else if (sSize == 2) {
           sWidth  = 600;
           sHeight = 400;
        }    var l = ( screen.availWidth - sWidth ) / 2;
        var  t = ( screen.availHeight - sHeight ) / 2;           
        nwin = window.open(url,sTitle,'left=' + l +',top=' + t +',width='+sWidth+',height='+sHeight+',scrollbars=yes,resizable=yes');      
        nwin.focus();      
    }
    </script>
    调整它的 left  height top  高度即可。
      

  3.   

    居中?楼主了解的浏览器太古老了。在我过去用的ie7(需要设置一下Tab方式)、以及现在用的ie8,直接在另一个Tab选项卡打开。在我使用的FireFox、Opera浏览器早就是如此。在很多人使用的其它浏览器也是如此。实际上那个操作已经没有什么意义了。