1 Code Java Keo Tha 2010-11-03, 08:43
winternight
Thành Viên
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test</title>
<style type="text/css">
#idTest{
position:absolute;
}
</style>
<script type="text/javascript" language="javascript">
window.onload = formLoad;
var Obj;
function formLoad()
{
Obj = document.getElementById("idTest");
Obj.style.top = "1px";
Obj.style.left = "1px";
}
function funcClick(e)
{
if(navigator.appName.indexOf('Internet')>-1)
{
e=window.event;
}
Obj.lastX=e.clientX;
Obj.lastY=e.clientY;
document.onmousemove=funcMove;
document.onmouseup=funcUp;
}
function funcMove(e)
{
if(navigator.appName.indexOf('Internet')>-1)
e=window.event;
var dx=e.clientX-Obj.lastX;
var dy=e.clientY-Obj.lastY;
Obj.style.left=(parseInt(Obj.style.left)+dx)+"px";
Obj.style.top=(parseInt(Obj.style.top)+dy)+"px";
Obj.lastX=e.clientX;
Obj.lastY=e.clientY;
}
function funcUp()
{
document.onmousemove=null;
document.onmouseup=null;
}
</script>
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="monhoc"></div>
<div id="idTest" onmousedown="funcClick();">Test</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test</title>
<style type="text/css">
#idTest{
position:absolute;
}
</style>
<script type="text/javascript" language="javascript">
window.onload = formLoad;
var Obj;
function formLoad()
{
Obj = document.getElementById("idTest");
Obj.style.top = "1px";
Obj.style.left = "1px";
}
function funcClick(e)
{
if(navigator.appName.indexOf('Internet')>-1)
{
e=window.event;
}
Obj.lastX=e.clientX;
Obj.lastY=e.clientY;
document.onmousemove=funcMove;
document.onmouseup=funcUp;
}
function funcMove(e)
{
if(navigator.appName.indexOf('Internet')>-1)
e=window.event;
var dx=e.clientX-Obj.lastX;
var dy=e.clientY-Obj.lastY;
Obj.style.left=(parseInt(Obj.style.left)+dx)+"px";
Obj.style.top=(parseInt(Obj.style.top)+dy)+"px";
Obj.lastX=e.clientX;
Obj.lastY=e.clientY;
}
function funcUp()
{
document.onmousemove=null;
document.onmouseup=null;
}
</script>
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="monhoc"></div>
<div id="idTest" onmousedown="funcClick();">Test</div>
</body>
</html>