SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: Code questions
-
Jan 29, 2001, 08:56 #1
- Join Date
- Sep 2000
- Location
- Oklahoma City, OK
- Posts
- 214
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:<html> <head> <title>Centered pop-up window</title> <SCRIPT LANGUAGE="JavaScript" type="text/Javascript"> function popUpCenteredWindow() { var iMyWidth; var iMyHeight; //gets top and left positions based on user's resolution so hint window is centered. iMyWidth = (window.screen.width/2) - (122 + 10); //half the screen width minus half the new window width (plus 5 pixel borders). iMyHeight = (window.screen.height/2) - (27 + 50); //half the screen height minus half the new window height (plus title and status bars). var win2 = window.open("","Window2","status,height=55,width=245,resizable=no,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=no"); win2.focus(); } </SCRIPT> </head> <body> <A HREF="javascript:void(0);" onClick="popUpCenteredWindow();">open a new window centered on the screen regardless of user's resolution. </A> </body> </html>
Can someone please explain what all I need to do...
Thanks
SR
-
Jan 29, 2001, 11:45 #2
- Join Date
- Mar 2000
- Location
- Muskegon, MI
- Posts
- 2,328
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You're going to want to put that script on the page you are popping from
Don't forget to add a URL in the href link.
-
Jan 30, 2001, 18:35 #3
- Join Date
- Sep 2000
- Location
- Oklahoma City, OK
- Posts
- 214
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ok ok, kind of a obvious answer...BUT...I am also wanting to know if there is a script much like this one...that I can change the size of the box. Maybe I should just turn the scrollbar on and hope for the best.
SR
-
Jan 30, 2001, 18:51 #4
- Join Date
- Mar 2000
- Location
- Muskegon, MI
- Posts
- 2,328
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Change the height and width attributes second to last line. But, NOT the iMyHeight and iMyWidth; those variables set the absolute distance from the upper left corner of the screen.
-
Jan 30, 2001, 22:39 #5
- Join Date
- Sep 2000
- Location
- Oklahoma City, OK
- Posts
- 214
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
K...thanks!!
SR
-
Jan 30, 2001, 23:15 #6
- Join Date
- Jan 2001
- Location
- England
- Posts
- 338
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Try this:
Code:<html> <head> <title>Javascript popup windows</title> <script language="javascript"> <!-- function openPopUp(WindowURL,WindowName,X,Y){ T = (window.screen.height/2) - (Y/2); L = (window.screen.width/2) - (Y/2); newPopUp = window.open(WindowURL,WindowName,'toolbar=no,location=no,directories=no,status=no,resizable=no,copyhistory=no,top='+ T +',left='+ L +',width=' + X +',height=' + Y) } //--> </script> </head> <body> <a href="#" onClick="openPopUp('http://www.mysite.com','myWindow',300,200)">window 1 size 300x200</a> <a href="#" onClick="openPopUp('http://www.mysite.com','myOtherWindow',350,250)">window 2 size 350x250</a> </body> </html>
<Edited by Drinky on 01-30-2001 at 11:25 PM>Drinky
Bookmarks