SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    Phil fillup07's Avatar
    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>

  2. #2
    Phil fillup07's Avatar
    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>
    I think that works correctly. If it doesn't, please let me know what is right.

    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!

  3. #3
    Web-coding NINJA! silver trophy beetle's Avatar
    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.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  4. #4
    Phil fillup07's Avatar
    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.
    That might work... how would I close the "opener" window?

    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?

  5. #5
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure thing. See this thread
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  6. #6
    Phil fillup07's Avatar
    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
    That wasn't *exactly* what I had in mind. Is there some way of using ASP and querystrings? See, my goal here is to make the link on each link to open a popup box as simple as possible (without javascript on that page)

    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-window
    Last edited by fillup07; Jul 28, 2002 at 03:18.

  7. #7
    Web-coding NINJA! silver trophy beetle's Avatar
    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?
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  8. #8
    Phil fillup07's Avatar
    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?
    So what code exactly would have to be on the opener window for it to open a new window, then close itself?

  9. #9
    Web-coding NINJA! silver trophy beetle's Avatar
    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();
    Last edited by beetle; Jul 28, 2002 at 07:49.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  10. #10
    Phil fillup07's Avatar
    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>

  11. #11
    Phil fillup07's Avatar
    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>

  12. #12
    Web-coding NINJA! silver trophy beetle's Avatar
    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');
    -- instead of --
    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');
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  13. #13
    Phil fillup07's Avatar
    Join Date
    May 2002
    Location
    Jacksonville, FL
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh really? Sweet... thanks!

  14. #14
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    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.
    thats only really with older browsers, but i would have thought that a popup in this context would be just fine as it is.

  15. #15
    Phil fillup07's Avatar
    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.
    I'm using IE6, and it didn't work. Although I think it might be because I didn't use the "return false"


    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •