Tech Today

[Javascript] Pop-up a new browser window with a fixed size

Posted on: May 16, 2009

One of my clients today asked me if I could send him some code that would effectively open a new browser window to a fixed height and width, with no menu bar.

This is a basic problem that might be worth knowing in the future. So here is the solution:

First you need to add this code between the <head></head> tags of your HTML document:

<script type="text/javascript">
function openpopup(address){
window.open(address,"","fullscreen=no,toolbar=no,status=no,
menubar=no,scrollbars=no,resizable=no,width=500,height=500");
}
</script>

Then you will need to create a link somewhere in your document. Like so:

<a href="javascript: openpopup('http://www.google.com')"> Click here to open the page in a new window. </a>

And vola! You are now able to open links in a new browser window! Now, this solution will also work for local html documents, but I believe it is always better practice to put the full URLs in anyways. Hope this solution works for you and enjoy!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: