Javascript: open new window with window.open()


What is window.open() in javascript?
window.open() is the javascript function tat use to open new window. Many advertiser use use this javascript window.open() function to pop up or open new window (or even pop under) for their advertisement.

How to use window.open() function?
To open a new window in javascript, simply follow the script below:-

window.open (“http://www.sillycorner.com”,”windowName”);

Below is the javascript window.open function details:-

window.open (url,windowname,attributes);

Advertisements

How to adjust the new window width, height and other element?
Just pass in the attributes (string without space) as the third arguement in the window.open() function.

window.open (“http://www.sillycorner.com”, “windowName”, “width=300,height=150,status=yes,location=no”);

The code above will open a new window width 300px, height 150px with status bar and no location bar, pointing to http://www.sillycorner.com.

Below are the attribute variables:-

height – int – height of the window in pixels. (example: height=300)
width – int – width of the window in pixels.
resizable – yes/no – Allow or disallow user to resize the window.
status – yes/no – The status bar at the bottom of the window
menubar – yes/no – The menu bar of the window
toolbar – yes/no – The standard browser toolbar with Back button.
location – yes/no – The URL bar.
scrollbars – yes/no – Hide or show the scrollbars

Technorati Tags: , , , , , , , , ,

Related posts:






Share this with your friends:-

5 Responses to “Javascript: open new window with window.open()”

  1. Hats off says:

    How to pass an object between windows in javaScript

  2. Gemstorm says:

    I totally agree with Gabriel…. why are you forcing people to look elsewhere when all you have to do is put a sample of the working code along with your article. Jeez!

  3. gabriel says:

    Everett, if someone is looking for the functions and utility of this code they should know before reading this tutorial how it’s used….c’mon… if you don’t know what parts go into the body or header you can just go test it and try or go shoot yourself…or give up javascript for life! ;D

  4. Everett says:

    Sigh… this is somewhat useful, but it’s always best to put in a verbatim example. Many newbies are not going to have any idea of what to do with the code listed. Does it go in an anchor tag? Should it be in within a script tag? It’s just a wasted opportunity if you put some of the details up and don’t show EXACTLY how it’s used.

Leave a Reply