日期:2014-05-17  浏览次数:20632 次

弹出自定义大小的窗口
在点击一个登录的超链接后,我想弹出一个自定义大小的弹出窗口,虽然我设置了窗口大小,但是360浏览器会自动最大化。我想知道该怎么做才能在一个页面上弹出一个自定义的小窗口用于用户登录。

------解决方案--------------------
探讨

恩,是的。但是有的网页我用360打开可以在中间弹出一个登录或者注册的小窗口,不知道该如何实现?

------解决方案--------------------
用window.showModalDialog()或window.showModelessDialog()也行。
------解决方案--------------------
var url = "自定义链接url";
var height = 窗口高度;
var width = 窗口宽度
showModalDialog(url,param,"dialogHeight:"+height+"px;dialogWidth:"+width+"px; center:Yes;help:No;resizable:No;status:No")
------解决方案--------------------
window.showModalDialog('../untitled4.html','1111','dialogWidth=700px;dialogHeight=500px;status=no');这个可以了- -@~~还是来晚啦
------解决方案--------------------
有些浏览器确实是这样,实在没办法的话,就用div模拟一个窗口也行啊。。


HTML code

<html>
    <head>
    <script>
        function reSizeWindow()
        {
            var shadow = document.getElementById("shadow");
            var dialog = document.getElementById("dialog");
            
            shadow.style.width = parseInt(document.body.clientWidth) + parseInt(document.body.scrollLeft);
            shadow.style.height = parseInt(document.body.clientHeight) + parseInt(document.body.scrollTop);
                
            dialog.style.left = parseInt(document.body.clientWidth)/2 - parseInt(dialog.style.width)/2 + parseInt(document.body.scrollLeft);
            dialog.style.top = parseInt(document.body.clientHeight)/2 - parseInt(dialog.style.height)/2 + parseInt(document.body.scrollTop);
        }
        function openWindow()
        {
            document.getElementById("shadow").style.display = "block";
            document.getElementById("dialog").style.display = "block";
            
            reSizeWindow();
        }
        function closeWindow()
        {
            document.getElementById("shadow").style.display = "none";
            document.getElementById("dialog").style.display = "none";
        }
    </script>
    <style type="text/css">
        .dialogStyle
        {
            background:red;
            position:absolute;
            display:none;
            text-align:right;
            z-index:2;
        }
        .shadowStyle
        {
            position:absolute;
            left:0px;
            top:0px;
            display:none;
            filter:alpha(opacity=30);
            opacity:0.3;
            background:gray;
            z-index:1;
        }
    </style>
    </head>
    <body style="margin:0px 0px 0px 0px;">
        <input type="button" onclick="openWindow()" value="open" style="margin-left:100px;margin-top:100px;"/>
        <div id="dialog" class="dialogStyle" style="width:200px;height:200px;">
            <input type="button" value="close" onclick="closeWindow()"/>
        </div>
        <div id="shadow" class="shadowStyle">
        </div>
        <!--width:200px;height:200px;background:red;position:absolute;display:none;text-align:right;z-index:2;-->
        <!--position:absolute;left:0px;top:0px;display:none;filter:alpha(opacity=30);opacity:0.3;background:gray;z-index:1;-->
        
        <script>
            window.onresize = function()
            {
                reSizeWindow();
            }
            window.onscroll = function()
            {
                reSizeWindow();
            }
            for(var i = 0;i < 100;i++)
            {
                document.write("<br