Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Javascript to open a "maximized" window in IE6?

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

like image 580
Roy Tang Avatar asked Jul 07 '09 03:07

Roy Tang


People also ask

How do I force a program to open maximized?

Maximizing the program on launchIn the Properties window, click the Shortcut tab (A). Locate the Run: section, and click the down arrow on the right side (red circle). In the drop-down menu that appears, select Maximized (B). Click Apply (C), and then click OK (D).

How to open Internet Explorer in maximized window?

Click Start, click Run, type gpedit. msc in the Open box, and then click OK. Expand Computer Configuration, expand Administrative Templates, expand Windows Components, and then click Internet Explorer. In the right pane, double-click the Enforce fullscreen mode setting.

How can we open a window in Javascript?

The open() method opens a new browser window, or a new tab, depending on your browser settings and the parameter values.

How do you maximize a window in HTML?

The key to maximizing the browser window in Javascript is the window. resizeTo() function, which would resize the window to any specified size.


4 Answers

Does this cause the same problems?

<script type="text/javascript">

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

</script>
like image 92
sakabako Avatar answered Oct 23 '22 04:10

sakabako


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);
like image 40
ars Avatar answered Oct 23 '22 04:10

ars


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();
}
like image 24
MadMurf Avatar answered Oct 23 '22 04:10

MadMurf


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

like image 42
ronapelbaum Avatar answered Oct 23 '22 05:10

ronapelbaum