SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Focus on a different browser window

    I have a page with several links that all open the link in a browser window called, "uploads".

    When the client goes back to the links window and clicks on another link, is there something in JavaScript that I can use to refocus on the "uploads" window as the newly clicked link is opened?

    Thanks!
    John

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi PHP John,

    You can have a look at this little script, or if that's overkill, extract what you need from the following. What you're looking for is the focus() method.

    Code:
    <html>
    <head>
    <script type='text/javascript'><!--
    var uploadsWin  = null;
    function winOpen(sUrl, iW, iH, iX, iY) {
      if (uploadsWin && !uploadsWin.closed) {
        uploadsWin.location.href = sUrl;
      }
      else {
        uploadsWin = window.open(sUrl, "uploadsWindow");
      }
      if (iW && iH) {
        uploadsWin.resizeTo(iW, iH);
        if (arguments.length > 3) {
          uploadsWin.moveTo(iX, iY);
        }
      }
      uploadsWin.focus();
      return false;
    }
    //--></script>
    </head>
    <body>
    <h2>winOpen() function</h2>
    <p><i>Open the first link in a new window,
    and all subsequent links in that window.</i></p>
    <p><a target='uploadsWindow' href='http://www.sitepoint.com/'
      onclick="return winOpen(this.href)">SitePoint.com</a></p>
    </body>
    </html>

  3. #3
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mike, thanks! I'll see if I can incorporate this as I need it. I'm building all these pages dynamically, so some of the scripts arguments will be changed dynamically as well.

    I'll let you know how it works!
    John


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
  •