SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    What's HTML?
    Join Date
    May 2001
    Location
    San Diego, CA
    Posts
    1,701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using window.open and window.bringToFront together

    Here's what I'm trying to do...

    I'm opening up small video clips in small Windows. I click the link, which properly uses window.open to open the idea clip Window and size it properly. Now, just say I leave this Window open but go and click another link. The video clip loads in the same Window (I used the naming attribute of window.open) BUT the Window disappears behind the main browser. Instead I need it to come back to the front, which would require window.bringToFront, but I can't figure out how to use the two together.

    Any help?
    Ryan Kuhle - A Proud Advisor - Got Questions? Just Ask!
    Get your website started for less than $20! Click Here

  2. #2
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this should do it...use the focus() method of the newly opened window in your popup function, e.g.

    Code:
    newwin=window.open(..........)
    newwin.focus();
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com

  3. #3
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function newPop(url,winName,winW,winH) {
    var newwin = window.open(url,winName,'width='+winW+',height='+winH+',left='+(window.screen.availWidth-winW)+',top=0');
    newwin.focus();
    newwin.resizeTo(winW,winH);
    newwin.moveTo(window.screen.availWidth-winW,0);
    }
    
    ...
    
    <a href="#" onclick="newPop('yellow.html','clipWin','500','500')">popWin<a>
    Also, as long as you use clipWin as the window name (second value) in the trigger link, the same window will be reused for each new clip.

    The above embellishment of redux's example allows you to specify the new dimensions of the clip window in the trigger link.

    I have also added a little bit to tuck the clip window into the top right corner as this area is less likely to be covered by the main window.
    It simply reduces the chances of the clip window becoming 'hidden' beneath the main window as the result of an errant click on the main window.
    Of course, remove that bit if you don't feel it is neccessary, wanted or useful.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  4. #4
    What's HTML?
    Join Date
    May 2001
    Location
    San Diego, CA
    Posts
    1,701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by redux
    this should do it...use the focus() method of the newly opened window in your popup function, e.g.

    Code:
    newwin=window.open(..........)
    newwin.focus();
    Worked perfect. Thanks!

    Bill, thanks for your help as well.
    Ryan Kuhle - A Proud Advisor - Got Questions? Just Ask!
    Get your website started for less than $20! Click Here


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
  •