最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

internet explorer - Using Javascript to open a "maximized" window in IE6? - Stack Overflow

programmeradmin6浏览0评论

Any idea for this?

Problems encountered: Using screen.availHeight and screen.availWidth as the height and width params in window.open causes the browser size to include the taskbar, and positioning at (0, 0) ignores the possibility of the taskbar being up there.

What I want is to open a new window with the size as if it was "maximized" by the user, i.e. it shouldn't cover the windows taskbar.

(Oh, and no need to remind me that users don't like Javascript interfering with their browser windows, etc. This is for an internal intranet webapp...)

Any idea for this?

Problems encountered: Using screen.availHeight and screen.availWidth as the height and width params in window.open causes the browser size to include the taskbar, and positioning at (0, 0) ignores the possibility of the taskbar being up there.

What I want is to open a new window with the size as if it was "maximized" by the user, i.e. it shouldn't cover the windows taskbar.

(Oh, and no need to remind me that users don't like Javascript interfering with their browser windows, etc. This is for an internal intranet webapp...)

Share Improve this question asked Jul 7, 2009 at 3:13 Roy TangRoy Tang 5,77110 gold badges48 silver badges75 bronze badges
Add a ment  | 

7 Answers 7

Reset to default 4

Does this cause the same problems?

<script type="text/javascript">

    window.moveTo(0,0);
    window.resizeTo(screen.width,screen.height);

</script>

This might get close to what you want:

window.moveTo(screen.width - screen.availWidth,
              screen.height - screen.availHeight);
window.resizeTo(screen.availWidth + screen.availWidth - screen.width,
                screen.availHeight + screen.availHeight - screen.height);

Try this for opening maximised and removing options to lock down users messing with your internal site. You can play around with the restrictions to suit your requirements.

function openFullscreen(url)
{

 // get the height correction for IE and set the window height and width
 var height = screen.availHeight;
 var width = screen.availWidth;

 var fullscreen = (document.all) ? "no" : "yes";
 var resizable = "no";
 var toolbar = "no";
 var status = "no";
 var left = 0;
 var top = 0;

 //set window properties
 props = "toolbar=no" +
 ",fullscreen=" + fullscreen +
 ",status=no" +
 ",resizable=no" +
 ",scrollbars=no" +
 ",menubar=no" +
 ",location=no" + ",";

 dims = "width="+ width +
 ",height="+ height +
 ",left="+ left +
 ",top=" + top;

 var win = window.open("", name, props + dims);
 win.resizeTo(width, height);
 win.location.href = url;
 win.focus();
}

Unfortunately, IE(8-) doesn't support the availLeft/availTop properties...

Taking a quick look at this, it seems

window.moveTo(screen.availLeft, screen.availTop);
window.resizeTo(screen.availWidth, screen.availHeight);

might be the best way to go - I believe this should return exactly the available screen width (It appears to work with on a single monitor if you have multiple monitors).

However it's not a perfect solution - If anyone else has any suggestions on how to open a real maximised window I'd be interested to hear

<script type="text/javascript">    
 window.moveTo(screen.width-screen.availWidth,screen.height-screen.availHeight);
 window.resizeTo(screen.availWidth,screen.availHeight);
</script>

This code opens a window maximized, but will it open links from that window maximized

I have base target=main just before the closing head tag. Very important that that code is the last tag before the closing head tag, and if any links in the page have the target="_parent.

Anything from your page will open full screen if the size is left out of a button code and if there is within the button code to specify a target tag go target="parent.

I tried all the codes but there maxed codes loose it after a few links oh.. and the way i just showed you makes a true maxed window not a sized floating window

发布评论

评论列表(0)

  1. 暂无评论