SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist
    Join Date
    May 2006
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    popup function, width + height not right

    Hello all, im using the following javascript function to popup a new window that will display the full size of thumbnail images.
    However, whenever I click on an image, the full image will not appear. Only a very small window will appear. How can I alter the function below so that the full image will appear?

    Code:
            function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=100%,height=100%');");
    }

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hint:

    height = number: Sets the height of the window in pixels.
    width = number: Sets the width of the window in pixels.

  3. #3
    SitePoint Evangelist
    Join Date
    May 2006
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    iis there no way I can tell the popup window to open up in full screen mode?

  4. #4
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Use browser detection to determine the width and height of the screen resolution then use those values in the window.open function.
    Ian Anderson
    www.siteguru.co.uk

  5. #5
    SitePoint Evangelist
    Join Date
    May 2006
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why would this not work?

    Code:
            function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="screen.width",height="screen.height"');");
    }

  6. #6
    SitePoint Evangelist
    Join Date
    May 2006
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    any ideas?

  7. #7
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are trying to concatenate a string to eval, but you are missing some + signs. Noone here will want to help with an eval anyway because it's just wrong. How about something like this:
    Code:
    //initialize the page object globally
    var page = {};
    ...
    //inside your popup function
    var day = new Date();
    var id = String(day.getTime());
    
    page[id] = window.open(URL, id, "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + screen.width + ",height=" + screen.height);
    note that the only reason to bother with the page object is if you want to activate the popup windows later on, and you really need to keep track of more than one of them. If not just do:
    Code:
    window.open(URL, "_blank", "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + screen.width + ",height=" + screen.height);


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
  •