Inner Resize Browser Window

This JavaScript function will resize the inside of a browser window to the dimensions provided.
function innerResizeWindow(innerWidth, innerHeight) {
	if (self.innerWidth) {
		myInnerWidth = self.innerWidth;
		myInnerHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth) {
		myInnerWidth = document.documentElement.clientWidth;
		myInnerHeight = document.documentElement.clientHeight;
	}
	else if (document.body) {
		myInnerWidth = document.body.clientWidth;
		myInnerHeight = document.body.clientHeight;
	}
	else {
		return;
	}
	adjustWidth = innerWidth - myInnerWidth;
	adjustHeight = innerHeight - myInnerHeight;
	window.resizeBy(adjustWidth, adjustHeight);
}
window.onload = innerResizeWindow(800,600);

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Thanks - Great Job!

ResizeBy does not work for Chrome. Are you aware of any solutions?

brett's picture

I have only used Chrome a little bit and so far have not needed this script to work in it.

What version are you using?

The latest version

this is great! thanks for your help

Thanks for this! Works great.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <b> <i> <strong> <cite> <em> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <css>, <diff>, <drupal5>, <html>, <javascript>, <php>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.