SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2012
    Location
    Brisbane Australia
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Bringing new window to foreground

    Hi everybody, I'm using the following code to open a new window, works just great, only thing is it goes to the background after user clicks on main window, so how does the user get it to the foreground again, I know it has something to do with windows.focus(); but thats all I know.

    <head>
    <script type="text/JavaScript">

    <!-- Begin
    function Openme(newin) {
    flyout=window.open(newin,"flyout","resizable=yes,alwaysRaised=yes,scrollbars=yes,width=500,height=700,top=150,left=900")
    var URL = document.form.site.options[document.form.site.
    selectedIndex].value;
    window.location.href = URL;
    }

    // End -->
    </script>
    </head>
    <body>

    <form name="form">
    <input type="button" value="Open me" onClick="Openme('../../html/0-9.html')">
    </form>

    </body>

    Any help as always is greatly appreciated, Cheers

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    You just need to focus the window, with flyout.focus();
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2012
    Location
    Brisbane Australia
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx for the reply paul_wilkins but it didn't work, does it have to be placed anywhere in particular, I put it straight after the window.location.href=URL; line and before the end curly brace, I clicked on the open me button again but nothing happens, Cheers

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by studentofIT View Post
    Thanx for the reply paul_wilkins but it didn't work, does it have to be placed anywhere in particular, I put it straight after the window.location.href=URL; line and before the end curly brace, I clicked on the open me button again but nothing happens, Cheers
    After you change the URL of the current page, it's kind of impossible for any other scripting to occur after that.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2012
    Location
    Brisbane Australia
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok so flyout.focus(); is pretty much useless as the window already initially loads in the foreground, then, what is a good work around, I know linking to it doesn't work either, what about putting an iframe on the main page instead, or a hidden div that loads when the open me button is clicked? The page that loads in the new window has a drop down menu that links to 26 other pages, the users need to copy and paste data from any or all of these pages to a form thats on the main page. Any ideas how to go about this? Cheers


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
  •