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...)
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).
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.
The open() method opens a new browser window, or a new tab, depending on your browser settings and the parameter values.
The key to maximizing the browser window in Javascript is the window. resizeTo() function, which would resize the window to any specified size.
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With