INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Applications

How do I create a popup window by onpnt
Posted: 14 Jun 02 (Edited 5 Nov 02)

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:openpopup()">Click here to see popup</a>
</body>

Happy Programming

Back to Javascript FAQ Index
Back to Javascript Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close