如何用单选按钮控制鼠标位置?

时间:2012-09-12 01:46:32

标签: javascript drag-and-drop

我有一个拖放div,一切正常,使用:

if  (document.getElementById){

(function(){
var n = 500;
var dragok = false;
var y,x,d,dy,dx;

function move(e){
if (!e) e = window.event;
 if (dragok){
  d.style.left = dx + e.clientX - x + "px";
  d.style.top  = dy + e.clientY - y + "px";
  return false;
 }
}

function down(e){
if (!e) e = window.event;
var temp = (typeof e.target != "undefined")?e.target:e.srcElement;
if (temp.tagName != "HTML"|"BODY" && temp.className != "dragclass"){
 temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
 }
if (temp.className == "dragclass"){
 if (window.opera){
  document.getElementById("Q").focus();
 }
 dragok = true;
 temp.style.zIndex = n++;
 d = temp;
 dx = parseInt(temp.style.left+0);
 dy = parseInt(temp.style.top+0);
 x = e.clientX;
 y = e.clientY;
 document.onmousemove = move;
 return false;
 }
}

function up(){
dragok = false;
document.onmousemove = null;
}

document.onmousedown = down;
document.onmouseup = up;

})();
}

如何添加两个单选按钮: 当检查标记为中心的单选按钮时,div将居中。

当我点击标有botton-right的单选按钮时,div移动到右下角。 ?

有什么办法可以在新功能中重复使用上述功能吗? 感谢

0 个答案:

没有答案