Roy Tang

Programmer, engineer, scientist, critic, gamer, dreamer, and kid-at-heart.

Blog Notes Photos Links Archives About

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…)

Comments

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();
}

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

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

Unfortunately, IE(8-) doesn’t support the availLeft/availTop properties…
<script type="text/javascript">    
 window.moveTo(screen.width-screen.availWidth,screen.height-screen.availHeight);
 window.resizeTo(screen.availWidth,screen.availHeight);
</script>