Advanced Search

Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Animated window opener

  1. #1
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    787
    Thanks
    85
    Thanked 2 Times in 2 Posts

    Default Animated window opener

    1) Script Title: Animated window opener

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...imatedwin2.htm

    3) Describe problem: Is it possible to make the screen as wide and high as the screen itself. In the script, it just fills up 98% of the screen.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    27,639
    Thanks
    42
    Thanked 2,896 Times in 2,868 Posts
    Blog Entries
    12

    Default

    Set these to 0:

    Code:
    var leftdist = 10;    // distance to left edge of window
    var topdist = 10;     // distance to top edge of window
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    787
    Thanks
    85
    Thanked 2 Times in 2 Posts

    Default

    Have done that. The problem is at the right and at the bottom. Can you add a var for that ?

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    27,639
    Thanks
    42
    Thanked 2,896 Times in 2,868 Posts
    Blog Entries
    12

    Default

    I see, the problem comes in when the winwidth and/or winheight are not evenly divisible by widthspeed or heightspeed, respectively. The fix is to do a final resize to winwidth and winheight after all the incremental resizing has played out:

    Code:
    <script type="text/javascript">
    
    //Animated Window- By Rizwan Chand (rizwanchand@hotmail.com)
    //Modified by DD for NS compatibility
    //Visit http://www.dynamicdrive.com for this script
    
    function expandingWindow(website) {
    var windowprops='width=100,height=100,scrollbars=yes,status=yes,resizable=yes'
    var heightspeed = 2; // vertical scrolling speed (higher = slower)
    var widthspeed = 7;  // horizontal scrolling speed (higher = slower)
    var leftdist = 0;    // distance to left edge of window
    var topdist = 0;     // distance to top edge of window
    
    if (window.resizeTo&&navigator.userAgent.indexOf("Opera")==-1) {
    var winwidth = window.screen.availWidth - leftdist;
    var winheight = window.screen.availHeight - topdist;
    var sizer = window.open("","","left=" + leftdist + ",top=" + topdist +","+ windowprops);
    for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed)
    sizer.resizeTo("1", sizeheight);
    for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed)
    sizer.resizeTo(sizewidth, winheight);
    sizer.resizeTo(winwidth, winheight);
    sizer.location = website;
    }
    else
    window.open(website,'mywindow');
    }
    
    </script>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    787
    Thanks
    85
    Thanked 2 Times in 2 Posts

    Default

    Works perfectly. Thanks !

  6. #6
    Join Date
    Dec 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Would it be difficult to allow each window open to be a different size, specified by the user? I'd like to be able to control the window size to fit some images of varying sizes (and even be able to specify yes/no to scrollbars).

  7. #7
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    787
    Thanks
    85
    Thanked 2 Times in 2 Posts

    Default

    I suppose you would have o change the following:
    Code:
    function expandingWindow(website) {
    var windowprops='width=100,height=100,scrollbars=no,status=yes,resizable=no'
    var heightspeed = 2; // vertical scrolling speed (higher = slower)
    var widthspeed = 7;  // horizontal scrolling speed (higher = slower)
    var leftdist = 50;    // distance to left edge of window
    var topdist = 100;     // distance to top edge of window

  8. #8
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    787
    Thanks
    85
    Thanked 2 Times in 2 Posts

    Default

    Or even better:

    Code:
    function expandingWindow(website) {
    var windowprops='width=50,height=70,scrollbars=no,status=yes,resizable=no'
    var heightspeed = 2; // vertical scrolling speed (higher = slower)
    var widthspeed = 7;  // horizontal scrolling speed (higher = slower)
    var leftdist = 50;    // distance to left edge of window
    var topdist = 100;     // distance to top edge of window
    But I suppose that these variables are in percentage, so it will not always be the exact size you want (depending on screen size)

  9. #9
    Join Date
    Dec 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    What I meant was that I need a way of calling the subroutine and passing variables to it (like width, height, scrollbars, etc.) for EACH call. That way, I could have each image open in a different sized window. Something like this:

    call WindowOpen('100','400','NO'); to open a 100 x 400 window

    or call WindowOpen('350','240','YES'); to open a 350 x 240 window

    I know I could just duplicate the script a dozen times on each page (with different size parameters) and call the one closest to the size I need, but I thought there might be some way to avoid having a dozen or more copies of essentially the same script, with only size or yes/no parameter differences.

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    27,639
    Thanks
    42
    Thanked 2,896 Times in 2,868 Posts
    Blog Entries
    12

    Default

    Code:
    function expandingWindow(website, name, width, height, top, left, scrollbars, status, resizable) {
    var windowprops='width='+width+',height='+height+',scrollbars='+scrollbars+',status='+status+',resizable='+resizable
    var heightspeed = 2; // vertical scrolling speed (higher = slower)
    var widthspeed = 7;  // horizontal scrolling speed (higher = slower)
    var leftdist = left;    // distance to left edge of window
    var topdist = top;     // distance to top edge of window
    
    if (window.resizeTo&&navigator.userAgent.indexOf("Opera")==-1) {
    var winwidth = window.screen.availWidth - leftdist;
    var winheight = window.screen.availHeight - topdist;
    var sizer = window.open("",name,"left=" + leftdist + ",top=" + topdist +","+ windowprops);
    for (sizeheight = 1; sizeheight < winheight; sizeheight += heightspeed)
    sizer.resizeTo("1", sizeheight);
    for (sizewidth = 1; sizewidth < winwidth; sizewidth += widthspeed)
    sizer.resizeTo(sizewidth, winheight);
    sizer.resizeTo(winwidth, winheight);
    sizer.location = website;
    }
    else
    window.open(website,name);
    }
    example call:

    Code:
    expandingWindow('http://www.google.com/', 'win1', 300, 250, 100, 150, 'yes', 'yes', 'yes')
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •