SitePoint Sponsor |
|
User Tag List
Results 1 to 15 of 15
Thread: Center/change Current Window
-
Jul 27, 2002, 12:32 #1
- Join Date
- May 2002
- Location
- Jacksonville, FL
- Posts
- 1,168
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Center/change Current Window
I've found a bunch of stuff online about opening a new window that is centered... but I want to center a current window (that is a popup, but I want to center it from within the page). I know how to resize from within the page. How do I center it?
Oh, and I'd also like to know how to take away the scrollbars, toolbars, statusbar, etc of the current window.
BTW, this is the code I use (and it works) to resize the window. I want to add on to it to do the other stuff as well:
Code:<script language="JavaScript"> window.resizeTo(500,100) </script>
-
Jul 27, 2002, 13:13 #2
- Join Date
- May 2002
- Location
- Jacksonville, FL
- Posts
- 1,168
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Okay, I played around and I got this:
Code:<script language="JavaScript"> var w = 500 var h = 200 window.resizeTo(w,h) var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2; window.moveTo(winl,wint) </script>
Now, I just want to know how (if possible) to get rid of the Status bar, Scroll bars, and Tool bars from the current window. Please help!
-
Jul 27, 2002, 18:04 #3
- Join Date
- Jul 2002
- Location
- Dallas, TX
- Posts
- 2,900
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I've never seen any code that lets you dynamically remove window elements. To the best of my knowledge, that can only be controlled at window creation.
You could open a new window will all the elements removed and have it load the document you want, and then close it's opener. Just a thought.
-
Jul 27, 2002, 20:38 #4
- Join Date
- May 2002
- Location
- Jacksonville, FL
- Posts
- 1,168
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by beetle
I've never seen any code that lets you dynamically remove window elements. To the best of my knowledge, that can only be controlled at window creation.
You could open a new window will all the elements removed and have it load the document you want, and then close it's opener. Just a thought.
See what I'm doing is starting off with a Main Page. What I want is just to have links that say like popup.asp?page=friday.htm
This is working fine (currently it opens a new window and the window resizes itself)... but I want that popop to have no toolbars, etc. The reason I was doing it this way instead of having a function to open a new window on the main page was b/c I didn't want all that extra code on every page. If there is a way to use a .js that I can use, I guess I would rather do that than have 3 windows going instead of 2... but I just wanted this to be pretty easy by having a one time thing using ASP where I didn't have to mess with a javascript function.
Any ideas?
-
Jul 27, 2002, 22:59 #5
-
Jul 28, 2002, 04:14 #6
- Join Date
- May 2002
- Location
- Jacksonville, FL
- Posts
- 1,168
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by beetle
Sure thing. See this thread
Should I just call an ASP function (maybe with global.asa or an just include file)....
Hmm... Tell me more about how to close the opener-windowLast edited by fillup07; Jul 28, 2002 at 04:18.
-
Jul 28, 2002, 06:56 #7
- Join Date
- Jul 2002
- Location
- Dallas, TX
- Posts
- 2,900
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well, you just reference the window's opener by 'window.opener' so to close it would be 'window.opener.close()'
I don't know ASP, so I'm not sure I can help ya there. Does each page open a different URL for the popup? What is the association?
-
Jul 28, 2002, 08:24 #8
- Join Date
- May 2002
- Location
- Jacksonville, FL
- Posts
- 1,168
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by beetle
Well, you just reference the window's opener by 'window.opener' so to close it would be 'window.opener.close()'
I don't know ASP, so I'm not sure I can help ya there. Does each page open a different URL for the popup? What is the association?
-
Jul 28, 2002, 08:47 #9
- Join Date
- Jul 2002
- Location
- Dallas, TX
- Posts
- 2,900
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:var w = 500 var h = 200 var winl = (screen.width - w) / 2; var wint = (screen.height - h) / 2; var features = "width="+w+", height="+h+", top="+wint+", left="+winl; window.open(top.location.href,'',features); top.close();
-
Jul 28, 2002, 14:53 #10
- Join Date
- May 2002
- Location
- Jacksonville, FL
- Posts
- 1,168
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Okay, I decided on how I want to do it (I think)... but I get a problem now:
Here's my page:
http://www.ax2.org/phil/popup.asp
There must be something wrong with the code, but I don't know what. When you click the link it opens the window, but the main window says "[object]"
Here's the link code...
Code:<a href="javascript:window.open('/shared/popup/extremeexcursion.asp', 'ax2popup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=150,left = 262,top = 284')">Extreme Excursion Info</a>
-
Jul 28, 2002, 15:07 #11
- Join Date
- May 2002
- Location
- Jacksonville, FL
- Posts
- 1,168
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It works... I did this:
Code:<a href="/shared/popup/extremeexcursion.asp" onclick="window.open('/shared/popup/extremeexcursion.asp', 'ax2popup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=150,left = 262,top = 284'); return false;">Extreme Excursion Info</a>
-
Jul 28, 2002, 18:07 #12
- Join Date
- Jul 2002
- Location
- Dallas, TX
- Posts
- 2,900
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
That's great! Sometimes the href="javsacript:function()" is less than reliable. But remember, setting a feature equal to 0 is the same as not including it at all! So your lines could be much shorter!
Code:window.open('/shared/popup/extremeexcursion.asp', 'ax2popup', 'width=500,height=150,left = 262,top = 284');
Code:window.open('/shared/popup/extremeexcursion.asp', 'ax2popup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=150,left = 262,top = 284');
-
Jul 28, 2002, 19:00 #13
- Join Date
- May 2002
- Location
- Jacksonville, FL
- Posts
- 1,168
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Oh really? Sweet... thanks!
-
Jul 28, 2002, 19:15 #14
- Join Date
- Aug 2001
- Location
- London
- Posts
- 2,475
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by beetle
[B]That's great! Sometimes the href="javsacript:function()" is less than reliable.
-
Jul 28, 2002, 19:28 #15
- Join Date
- May 2002
- Location
- Jacksonville, FL
- Posts
- 1,168
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by Andrew-J2000
thats only really with older browsers, but i would have thought that a popup in this context would be just fine as it is.
Guys, here is my latest problem pertaining this popup stuff:
http://sitepointforums.com/showthrea...threadid=70051
Its in the ASP forum because that is what the problem is really about - mixing ASP and Javascript. If you can help me out, please do in that thread. Thanks
Bookmarks