Got one easy question for you, but still hard for me... All i'm trying to do, is maximize new, opened window with different button...But it doesn't work, cant figure out why .. can someone please tell me, what i do wrong?
<form>
<input type="button" value="Create New Window" onclick="createWindow()" />
<input type="button" value="Maximize New Window" onclick="maximizeWindow()" />
</form>
var maxWindow;
function createWindow(){
var winWidth = 300;
var winHeight = 100;
var winLeft = (screen.width - winWidth)/2;
var winTop = (screen.height - winHeight)/2;
var winOptions = ",width=" + winWidth + ",height=" + winHeight + ",left=" + winLeft + ",top=" + winTop;
maxWindow = window.open("http://www.google.com","newWindow",winOptions);
maxWindow.focus();
}
function maximizeWindow() {
maxWindow.moveTo(0,0);
maxWindow.resizeTo(screen.availWidth, screen.availHeight);
maxWindow.focus();
}
asked Sep 7, 2013 at 18:02
MrPaulius
1071 gold badge3 silver badges10 bronze badges
1 Answer 1
<script>
var maxWindow;
function createWindow(){
var winWidth = 300;
var winHeight = 100;
var winLeft = (screen.width - winWidth)/2;
var winTop = (screen.height - winHeight)/2;
var winOptions = ",width=" + winWidth + ",height=" + winHeight + ",left=" + winLeft + ",top=" + winTop+'fullscreen=yes';
maxWindow = window.open("http://www.google.com","newWindow",winOptions);
maxWindow.focus();
}
function maximizeWindow() {
maxWindow.moveTo(0,0);
maxWindow.resizeTo(screen.width, screen.height);
maxWindow.focus();
}
</script>
<form>
<input type="button" value="Create New Window" onclick="createWindow()" />
<input type="button" value="Maximize New Window" onclick="maximizeWindow()" />
</form>
i add this to first function 'fullscreen=yes' and in second function change second line with my code maxWindow.resizeTo(screen.width, screen.height);
answered Sep 7, 2013 at 18:19
Ankit Agrawal
6,1246 gold badges28 silver badges49 bronze badges
Sign up to request clarification or add additional context in comments.
4 Comments
Alnitak
please don't submit "spot the difference" answers.
Ankit Agrawal
i add this to first function 'fullscreen=yes' and in second function change second line with my code maxWindow.resizeTo(screen.width, screen.height);
Alnitak
so put that in your answer!
Dave Chen
I believe the question is how to
maximize new, opened window with different button. This code instantly maximizes the window on the first button click. I do not think that this will work for the OP.default