Opening javascript popup window without address bar and title with height and width set in percentage according to screen resolution

北战南征 提交于 2019-12-08 02:41:34

问题


I want to open popup window using javascript with no title and address bar and also want to set its height and width in percentage according to screen resolution.How can i achieve this. I did this code;

 function popitup(url) {

        LeftPosition = (screen.width) ? (screen.width - 800) / 2 : 0;
        TopPosition = (screen.height) ? (screen.height - 700) / 2 : 0;
        var sheight = (screen.height) * 0.9;
        var swidth = (screen.width) * 0.8;          

        settings = 'height='+ sheight + ',width='+ swidth + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=yes,resizable=yes,toolbar=no,status=no,menu=no, directories=no,titlebar=no,location=no,addressbar=no'

        newwindow = window.open(url, '', settings);
        if (window.focus) { newwindow.focus() }
        return false;
    }

but still i can see address and title bar.Is this is relative versions and type of browser?.If so how can i achieve these settings in latest versions of browser like IE9,Chrome,Firefox and safari?


回答1:


For security reasons, this is not possible.

Check out http://www.codeproject.com/Questions/79625/How-to-hide-title-bar-in-Javascript-popup

You may use alternatives like modal dialogs which more appealing. Most JS libraries provide modal dialogs out of the box or by using plugins.




回答2:


Is it supposed to be menu = no or menubar = no??

settings = 'width='+w+',height='+h+',top='+top+', left='+left+',menubar=no,resizable=no,scrollbars=yes,location=no,toolbar=no' worked fine for me.



来源:https://stackoverflow.com/questions/13174812/opening-javascript-popup-window-without-address-bar-and-title-with-height-and-wi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!