Results 1 to 4 of 4

Thread: DHTML Window Widget Window Positioning

  1. #1
    Join Date
    Mar 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default DHTML Window Widget Window Positioning

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

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/

    3) Describe problem:
    I've implemented this script on my site, and am interested in saving window positioning AFTER the page is refreshed. I have it all thought out, but am having a hard time figuring out how to retrieve a window's positioning. I've tried looking into the getviewpoint function, but can't quite see where the values (preferably coordinates) would come from. Any ideas?

  2. #2
    Join Date
    Mar 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    So, here's a start. This is what I've tried:

    I created a getleft function to return t.lastx, which is generated in rememberattrs
    Code:
    getleft:function(t){
    	dhtmlwindow.rememberattrs(t)
    	return t.lastx //position window to last known x coord just before minimizing
    },
    Here's rememberattrs:
    Code:
    rememberattrs:function(t){ //remember certain attributes of the window when it's minimized or closed, such as dimensions, position on page
    	this.getviewpoint() //Get current window viewpoint numbers
    	t.lastx=parseInt((t.style.left || t.offsetLeft))-dhtmlwindow.scroll_left //store last known x coord of window just before minimizing
    	t.lasty=parseInt((t.style.top || t.offsetTop))-dhtmlwindow.scroll_top
    	t.lastwidth=parseInt(t.style.width) //store last known width of window just before minimizing/ closing
    },
    But when I call this getleft function from my test page, I receive an undefined value.
    Code:
    var left = time.getleft();
    alert(left);     // undefined
    Any help is greatly appreciated! All I want is to be able to retrieve these positioning values.

  3. #3
    Join Date
    Mar 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    'Still stuck. Any ideas, anyone?

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

    Default

    Actually to get the coordinates of a DHTML window, all you should have to do is probe the window object's left and top properties, and not t.lastx or t.lasty. So say you've opened a DHTML window using the code:

    Code:
    var googlewin=dhtmlwindow.open("googlebox", "iframe", "http://google.com", "Google Web site", "width=700px,height=450px,resize=1,scrolling=1,center=1", "recal")
    To get this window's last x and y coordinates at anything, you can just do:
    Code:
    var xpos=googlewin.style.left
    var ypos=googlewin.style.top
    You may want to check out this thread, which contains an example of getting the last coordinates of a DHTML window and stores it in a cookie. When the same window is loaded on another page, those coordinates are used to reposition the window so they mirror the previous page's.
    DD Admin

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
  •