PDA

View Full Version : DHTML Window script



manitoon
09-28-2005, 07:22 AM
DHTML Window
http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow.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



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



document.getElementById(dwindow).onmousemove= drag_drop


I thought If i modify the above line
like


document.getElementById(dwindow).onmousemove= drag_drop(e,dwindow)

it would pass the name of window and it does

the function would be


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

Twey
09-28-2005, 02:57 PM
Your incorrect assumption is that e is the window id. It is not.
You should rewrite the function to take an id:


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.

manitoon
09-29-2005, 08:46 AM
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

document.getElementById(dwindow).onmousemove= drag_drop(e,dwindow)

Error is generated saying "Not Implmented"

and i call


document.getElementById(dwindow).onmousemove= drag_drop

This way it works fine

ofcourse i change the function defination accordingly when calling

Twey
09-29-2005, 03:14 PM
Try:

document.getElementById(dwindow).onmousemove= "drag_drop(e,dwindow);"