Skip to content

Instantly share code, notes, and snippets.

@arvindr21
Created November 24, 2014 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arvindr21/b0ac9237bfe5ea39d41c to your computer and use it in GitHub Desktop.
Save arvindr21/b0ac9237bfe5ea39d41c to your computer and use it in GitHub Desktop.
Resize a popup window using javascript
var i=0;
function resize() {
i=0;
// if (navigator.appName == 'Netscape') i=20;
if (window.navigator.userAgent.indexOf('MSIE 6.0') != -1 && window.navigator.userAgent.indexOf('SV1') != -1) {
i=30; //This browser is Internet Explorer 6.x on Windows XP SP2
} else if (window.navigator.userAgent.indexOf('MSIE 6.0') != -1) {
i=0; //This browser is Internet Explorer 6.x
} else if (window.navigator.userAgent.indexOf('Firefox') != -1 && window.navigator.userAgent.indexOf("Windows") != -1) {
i=25; //This browser is Firefox on Windows
} else if (window.navigator.userAgent.indexOf('Mozilla') != -1 && window.navigator.userAgent.indexOf("Windows") != -1) {
i=45; //This browser is Mozilla on Windows
} else {
i=80; //This is all other browsers including Mozilla on Linux
}
if (document.documentElement && document.documentElement.clientWidth) {
frameWidth = document.documentElement.clientWidth;
frameHeight = document.documentElement.clientHeight;
window.moveTo(0, 0);
// window.resizeTo(imgWidth, imgHeight);
window.resizeTo(screen.width,screen.height+i);
}
else if (document.body) {
window.resizeTo(document.body.clientWidth, document.body.clientHeight-i);
}
self.focus();
}
setTimeout(function(){
resize();
}, 99);
@Zoli-GitHub
Copy link

var i=0;
function resize() {
i=0;
// if (navigator.appName == 'Netscape') i=20;
if (window.navigator.userAgent.indexOf('MSIE 6.0') != -1 && window.navigator.userAgent.indexOf('SV1') != -1) {
i=30; //This browser is Internet Explorer 6.x on Windows XP SP2
} else if (window.navigator.userAgent.indexOf('MSIE 6.0') != -1) {
i=0; //This browser is Internet Explorer 6.x
} else if (window.navigator.userAgent.indexOf('Firefox') != -1 && window.navigator.userAgent.indexOf("Windows") != -1) {
i=25; //This browser is Firefox on Windows
} else if (window.navigator.userAgent.indexOf('Mozilla') != -1 && window.navigator.userAgent.indexOf("Windows") != -1) {
i=45; //This browser is Mozilla on Windows
} else {
i=80; //This is all other browsers including Mozilla on Linux
}
if (document.documentElement && document.documentElement.clientWidth) {
frameWidth = document.documentElement.clientWidth;
frameHeight = document.documentElement.clientHeight;

window.moveTo(0, 0);

// window.resizeTo(imgWidth, imgHeight);
window.resizeTo(screen.width,screen.height+i);
}
else if (document.body) {
window.resizeTo(document.body.clientWidth, document.body.clientHeight-i);
}
self.focus();
}

setTimeout(function(){
resize();
}, 99);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment