Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I create a popup window

Applications

How do I create a popup window

by  onpnt  Posted    (Edited  )
I would like feed back on this FAQ seeing as it is referenced so much here. If anyone has anything to add to it or change on it please let me know and I will make the changes so we can all have a well established FAQ on this topic.

IMPORTANT
follow this link and read the article. this is important to how you have your popup's created in your event. A simple modification to the syntax can make things flow a lot smoother.

http://youngpup.net/_ui_webapp/getFrames.asp?request=/articles/how-to-create-popups.xml

This was article was provided for us by xutopia
Thanks

Generating popup windows with JavaScript
Generating popup windows is one of the more simplified functions in JavaScript, but also is one of the most frequently questioned in how to create one.

Basic syntax for a popup window (or simply the creation of a window)

WindowHandle = window.open([URL [,windowName [,features]]])

windowHandle = this variable is created to hold the value of the new window
In order to perform functions such as closing.
URL = the target page to open
WindowName = often either given the value of current Time or "," value. This can be used to load separate documents into the page.
Features = there is a wide array of features that can be manipulated in this attribute. The most common are as follows
Width = [specify]
Height = [specify]
For centering your new window use this formula.
var centerWidth=(screen.width/2)-(300/2);
var centerHeight=(screen.height/2)-(300/2);
The only changes needed to be made to this formula is the width (300) and height (300)
The final line would appear like this
"height=300,width=300,top="+centerHeight+",
left="+centerWidth+"";

The following features can all be set to "=0" if they are not wanted to be in the popup window.
toolbar, location, directories, status, scrollbars, menubar, resizable
The following example would be a popup window with a border only as a feature and centered on the users page.




<script>
function openpopup(){
var centerWidth=(screen.width/2)-(300/2);
var centerHeight=(screen.height/2)-(300/2);
winpops=window.open("thanks.htm","","height=300,width=300,top="+centerHeight+",left="+centerWidth+",toolbar=0,location=0,directories=0,
status=0,scrollbars=0,menubar=0,resizable=0,")
}
</script>
<body>
<a href="javascript:eek:penpopup()">Click here to see popup</a>
</body>

Happy Programming
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top