SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    window.open() is not on top

    I have tried everything I can think of but my window.open() does not stay on top of the parent window. Is there a reason why?

    var g_ie = window.XMLHttpRequest;
    if (g_ie) {
    var windowURL = urlWithoutQuerystring + "?" + querystring;
    }
    else {
    var windowURL = urlWithoutQuerystring + "?" + querystring + "&print=true";
    }

    window.open(windowURL, 'window', 'status=1, scrollbars=1, resizable=1, width=800, height=700, left=0, top=0');
    window.setStyle('zIndex', 1000000);
    window.focus();
    window.print();
    break;



    Thanks for reading and for any help

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,608
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    You have given the new window the name 'window' in the open command but the window object in the JavaScript refers to the current window and so after you open the new window you give the focus back to the current window and then print the current window.

    Try this instead

    var newwindow = window.open(windowURL, 'newwindow', 'status=1, scrollbars=1, resizable=1, width=800, height=700, left=0, top=0');
    newwindow.focus();
    newwindow.print();
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


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
  •