SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict
    Join Date
    Feb 2000
    Location
    New York
    Posts
    307
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Keeping a window on top

    I am opening a "customized" pop-up window from a link using onClick="window.open('blah','blah','blah');return false" . Can anyone tell me what I add to the parameter list to keep the pop-up window always on top? Thanks.
    Ted

  2. #2
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use a function instead.

    onclick=openWin()

    function openWin()
    {
    var newWin=window.open('blah','blah','blah');
    newWin.focus();
    }

    That also promotes reusability as you can create a function that will work anywhere simply by adding a url as a passable variable.
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  3. #3
    SitePoint Columnist Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thankfully it is impossible to force a javascript window to always stay on top (can you imagine what pop up ads would be like if they could do that!?)

  4. #4
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    True enough. I do hate popups. But sometimes giving focus to a popup is useful (I sometimes use popups for quick and dirty forms).

    Perma ontop. I am sure there is a script you 'could' make to do this. It would be a truly evil experience.
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  5. #5
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actualy you can keep it on top by placing this in the body tag of the popup:
    <BODY onBlur="this.focus()">

    There are valid reasons for keeping a popup on top such as being used for navigation purposes.

  6. #6
    SitePoint Columnist Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by requestcode
    Actualy you can keep it on top by placing this in the body tag of the popup:
    <BODY onBlur="this.focus()">

    There are valid reasons for keeping a popup on top such as being used for navigation purposes.
    That doesn't work in Mozilla or IE6 (IE6 keeps flashing the window in my taskbar but doesn't switch back to it). I honestly can't see any reason for using this other than to drive visitors away from your site - I know any site that tries to take over my desktop like that goes straight on my "never visit again" list.

  7. #7
    SitePoint Addict
    Join Date
    Feb 2000
    Location
    New York
    Posts
    307
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Let me clarify. The pop-up to which I referred is actually a small window containing a chat applet that is launched specifically by the visitor, and they can close it any time they wish. Personally, I would never do that to a pop-up ad, or even use pop-ups... they are the scurge of the Internet

    Maelstrom, would I just place the ofunction part after the first with no puncuation?... I am a little unclear as to the syntax. Like onclick=openWin()function openWin(){var newWin=window.open('blah','blah','blah'); newWin.focus();} ?

    Thanks requestcode, I'll give your suggestion a try too to test the results of each.

    Skunk, when the task is flashing on your task bar, does it do anything else? It still just functions like any other window? Is it annoying?

    Thanks all
    Ted

  8. #8
    SitePoint Columnist Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Ted
    Skunk, when the task is flashing on your task bar, does it do anything else? It still just functions like any other window? Is it annoying?
    It's a tiny bit annoying but nothing to get upset about. My point was more that the technique doesn't work (it doesn't keep the window on top of everything else) so there's probably no point in using it.


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
  •