Popup Windows
Opening New/Popup Windows
Show Both MethodsMethod 1 (Beginner)
This method is the easiest way to open a new, named window from a hyperlink (as opposed to the default behavior of having the new webpage open in the same window). No javascript is required to open the new window, however the developer has no control over the size or properties of the window. The resulting window will be a standard browser window, and will either be maximized or the size of the last non-maximized window that the user closed normally.Additional web content can be 'pushed' to the new window by putting a 'target' property in the anchor tag and using the window name. Similarly, javascript can be used to close the new window by from the initial window by invoking the self.close() method and targetting the new window by name.
To implement, create two popup window pages - popup.html and popup2.html. Then put this HTML code in your starting webpage:
<a href="popup.html" target="myWindow">Open window ("myWindow")</a><br />
<a href="popup2.html" target="myWindow">Push content to myWindow</a><br />
<a href="javascript: self.close();" target="myWindow">Close myWindow</a>
Try it out:
<a href="popup2.html" target="myWindow">Push content to myWindow</a><br />
<a href="javascript: self.close();" target="myWindow">Close myWindow</a>