document.onmousedown document.onmousemove Problem?

G

Gary Mayor

Hi,
I'm using document.onmousedown then document.onmousemove to draw a <div
line. The trouble is when the mouse is pressed down it moves the line a
bit but then stops moving it and looks like it's trying to drag the
image. I'm using mozilla(linux) and tried it windows but it doesn't work
as i've got the wrong commands for explorer. I've got some other code
that works but i can't see the difference here's the code i've got so
far if anyone knows please please let me know.

<HTML>
<body bgcolor="FFFFFF">

<img name="main" border="1" src="iecadaptor.jpg">

<div id="top2" style="position:absolute; width:308px; height:1px;
z-index:1; left: 29px; top: 23px; overflow: visible; visibility: hidden;
background-color: black; layer-background-color: black; border: 1px none
#000000"></div>

<script language="javascript">
<!---
var netscape = (document.layers) ? 1:0;
var goodIE = (document.all) ? 1:0;
var netscape6 = (document.getElementById && !document.all) ? 1:0;
var height = 100;
var width = 100;
var left = 50;
var top = 60;
var visible = false;
var mouseX = 0;
var mouseY = 0;
var mousedn = false;
var hspc = 40;
var vspc = 9;
var name = 'secondtop';

document.getElementById("top2").style.visibility="visible";

function mousedown(e)
{
//document.writeln("hello");
//document.getElementById("top2").style.visibility="visible";
mouseX = e.pageX;
mouseY = e.pageY;
mouseX = mouseX - 29;
mouseY = mouseY - vspc;
document.getElementById("top2").style.width=mouseX;
mousedn = true;
//alert(width);
//var thing;
}

function getXY(e)
{
if(mousedn) {
width = width - 1;
mouseX = e.pageX;
mouseY = e.pageY;
mouseX = mouseX - 29;
mouseY = mouseY - vspc;
document.getElementById("top2").style.width=mouseX;
//alert("Mouse Move");
}
}

function mouseisup(e)
{
mousedn = false;
//alert("Mouse UP");
}

document.onmousemove = getXY;
document.onmousedown = mousedown;
document.onmouseup = mouseisup;

// -->
</script>
</body>
</html>

Thanks

Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top