Results 1 to 5 of 5

Thread: Centered DHTML Window widget: reposition on browser resize?

  1. #1
    Join Date
    Aug 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Centered DHTML Window widget: reposition on browser resize?

    1) Script Title: DHTML Window widget (v1.03)

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

    3) Describe problem: Is it possible to extend/modify the script which centers the popup, so that if a user resizes the browser window the popup automatically repositions itself to remain in the centre of the browser window?

    I'm not a great coder so please be gentle. LOVE the widget!

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Sure, inside the .js file, try finding the line and add to it:

    Code:
    t.isResize(getValue("resize")) //Set whether window is resizable
    this.addEvent(window, function(){t.moveTo(xpos, ypos)}, "resize")
    The code in red is new.

  3. #3
    Join Date
    Aug 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That's great! Thanks ddadmin. Now I know this is going to sound greedy, but is there any way this repositioning can be done on the fly ie. the popup moves AS the user resizes the browser window, as opposed to when the browser resizing stops! Really grateful, either way!

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Hmmm there may be a way, but I can just imagine the unnecessary complexity in coding required and the number of things that can go wrong. You may have a situation where the browser calls dhtmlwindow.moveTo() incesssantly in a loop. Right now all I'm doing is relying on the onresize event handler, which is as efficient and stable as it gets.

  5. #5
    Join Date
    Aug 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the help dd. I think I've been getting a little ahead of myself with coding! I've managed to find a solution showing and hiding a div which pulls in external content and uses margin:auto to centralize. Loving the DD site though. Lots to explore!

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
  •