Results 1 to 4 of 4

Thread: DHTML Window script

  1. #1
    Join Date
    Sep 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default DHTML Window script

    DHTML Window
    http://www.dynamicdrive.com/dynamici...htmlwindow.htm


    I am trying to modify this script a little
    My issue was that I had to be able to open multiple dhtml windows in a same broswer.

    I was successfull to some extent. By i cant move the windows now.
    the problem is here

    Code:
    function drag_drop(e){
    if (ie5&&dragapproved&&event.button==1){
    document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
    document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
    }
    
    else if (ns6&&dragapproved){
    document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
    document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
    }
    Now What i want to do is when i call this function i pass the name of the window which need to be moved. right ?

    So I need to pass the value of dwindow when i call this function
    Thisfunction is called by the line below

    Code:
    document.getElementById(dwindow).onmousemove= drag_drop
    I thought If i modify the above line
    like
    Code:
    document.getElementById(dwindow).onmousemove= drag_drop(e,dwindow)
    it would pass the name of window and it does

    the function would be
    Code:
    function drag_drop(e,dwindow){
    if (ie5&&dragapproved&&event.button==1){
    document.getElementById(dwindow).style.left=tempx+event.clientX-offsetx+"px"
    document.getElementById(dwindow).style.top=tempy+event.clientY-offsety+"px"
    }
    
    else if (ns6&&dragapproved){
    document.getElementById(dwindow).style.left=tempx+e.clientX-offsetx+"px"
    document.getElementById(dwindow).style.top=tempy+e.clientY-offsety+"px"
    }

    But when I do this . the values is passed but I get this error
    NOT IMPLEMENTED ..

    and the moving of window doesnt work.

    I hope I have made myself clear
    I need help here

    Thanks

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Your incorrect assumption is that e is the window id. It is not.
    You should rewrite the function to take an id:

    Code:
    function drag_drop(e, winid){
    if (ie5&&dragapproved&&event.button==1){
    document.getElementById(winid).style.left=tempx+event.clientX-offsetx+"px"
    document.getElementById(winid).style.top=tempy+event.clientY-offsety+"px"
    }
    
    else if (ns6&&dragapproved){
    document.getElementById(winid).style.left=tempx+e.clientX-offsetx+"px"
    document.getElementById(winid).style.top=tempy+e.clientY-offsety+"px"
    }
    You now need to change the code wherever the function is called and make sure it passes the correct id as the second argument.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Sep 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    yes i tried to pass the winid I am sure i was passing the correct one

    The problem is from where i call the function.

    If I call the function this way
    Code:
     document.getElementById(dwindow).onmousemove= drag_drop(e,dwindow)
    Error is generated saying "Not Implmented"

    and i call

    Code:
    document.getElementById(dwindow).onmousemove= drag_drop
    This way it works fine

    ofcourse i change the function defination accordingly when calling

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Try:
    Code:
    document.getElementById(dwindow).onmousemove= "drag_drop(e,dwindow);"
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •