Closed Thread Icon

Preserved Topic: Help needed please.... Pages that link to <a href="https://ozoneasylum.com/backlink?for=18540" title="Pages that link to Preserved Topic: Help needed please...." rel="nofollow" >Preserved Topic: Help needed please....\

 
Author Thread
pwhitrow
Bipolar (III) Inmate

From: UK
Insane since: Feb 2002

posted posted 06-26-2002 18:45

Guys,
I' writing a small auto window generator script, but am having a slight problem.
The functions I have to move the window while holding the mouse button down are not working corectly.
If you move the mouse too quick, the window gets left behind.
Any ideas...????
-------------------------------------------------------
<html>
<head>
<title></title>


<script language="JavaScript">
<!--
var dragWinObj,x,y

function moveWin(){
if (event.button==1){
if(dragWinObj!=null){
if(dragWinObj.type=='dragWin'){
dragWinObj.style.pixelLeft=PL+event.clientX-x
dragWinObj.style.pixelTop=PT+event.clientY-y
return false
}
}
}
}

function dragWin(what){
x=event.clientX
y=event.clientY
dragWinObj=what
PL=dragWinObj.style.pixelLeft
PT=dragWinObj.style.pixelTop
dragWinObj.style.cursor='move'
}

function dropWin(){
dragWinObj.style.cursor='default'
}

function closeWin(what){
document.getElementById(what).style.display='none'
}

titleTxtFont= 'ms sans serif'
titleBgColor= 'activecaption'
titleTxtColor= 'captiontext'
titleStyle= ''
//titleStyle= 'filterrogidXImageTransform.Microsoft.gradient(enabled=\'true\',gradientType=\'1\',startColorstr=\'#800000\', endColorstr=\'white\')'
mainBgColor= 'Window'

function makeWindow(where,T,L,H,W,title,titlePic){
document.getElementById(where).innerHTML='<table border="0" cellspacing="0" style="position:absolute;top:'+T+';left:'+L+';width:'+W+';height:'+H+';cursor:default;border:2 outset;z-index:1000;" type="dragWin"><tr onmousedown="dragWin(this.parentElement.parentElement)" onmouseup="dropWin()" onmousemove="moveWin()" onselectstart="return false;" style="background:'+titleBgColor+';color:'+titleTxtColor+';font-family:'+titleTxtFont+';font-size:10;height:20;"><td style="height:20;'+titleStyle+'"><img align="absmiddle" src="'+titlePic+'" width="17" height="15" border=0 alt="" ondragstart="return false"><b>'+title+'</b><div style="position:absolute;top:1;right:1;height:0;font-family:webdings;font-size:10;width:15;cursorointer;" align="center" onclick="closeWin(\''+where+'\')" title="Close"><b>r</b></div></td></tr><tr><td cellpadding="5" style="border:1 inset;background:'+mainBgColor+';" valign="top"><div id="'+where+'_body" style="height:100%;width:100%;overflow:auto;"></div></td></tr></table>'
}

//-->
</script>

</head>

<body>

<div id="win_1">
<script>
makeWindow('win_1',100,100,300,450,'Window 1','computer.gif')
win_1_body.innerHTML='Test Window<br><br>Test Window<br><br>Test Window<br><br>Test Window<br><br>Test Window<br><br>Test Window<br><br>Test Window<br><br>Test Window<br><br>Test Window<br><br>Test Window<br><br>Test Window<br><br>Test Window<br><br>Test Window<br><br>Test Window<br><br>Test Window<br><br>Test Window<br><br>Test Window<br><br>Test Window<br><br>Test Window<br><br>'
</script>
</div>

</body>
</html>


http://www.pwhitrow.com

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 06-26-2002 19:03

Seeing a working version of the script will probably help us to figure out what's wrong.

pwhitrow
Bipolar (III) Inmate

From: UK
Insane since: Feb 2002

posted posted 06-26-2002 19:27

Slime,

Here's a link..
http://www.pwhitrow.com/window.html

www.pwhitrow.com

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 06-26-2002 20:28

hmm... I'm a bit skeptical of the onmousedown in tr tags. Not that it's totally unsupported but that just seems hinky to me.


othewise.

You shouldn't need two functions onMouseDown and onMouseMove. Just the mousedown should be sufficient. I'd put the onmousemove in the general body tags...
window.onmousemove = track;
function track{
mousex = event.x;
mousey = event.y;
}

There now you have the mousepos in 2 vars:
relative to the whole page.



.:[ Never resist a perfect moment ]:.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 06-26-2002 20:45

Yup, yup, that's exactly the problem. You need the onmousemove to be effective *everywhere*. When the user moves their mouse out of the TD, the TD's onmousemove event is no longer called, so the window's position is never updated.

So bitdamaged's solution should work.

Good script though.

pwhitrow
Bipolar (III) Inmate

From: UK
Insane since: Feb 2002

posted posted 06-26-2002 21:31

Thanks all.

Just adding 'document.onmousemove=moveWin' into the main script area works a treat.
Can now develop this script further.......

www.pwhitrow.com

« BackwardsOnwards »

Show Forum Drop Down Menu