2011-09-07 65 views

回答

6

創建一個樣式類是這樣的:

.unselectable { 
    -moz-user-select: none; 
    -khtml-user-select: none; 
    -webkit-user-select: none; 
    user-select: none; 
    -ms-user-select : none 
} 

然後更改JavaScript稍微對鼠標按下分配這個類。所以從這個不變的腳本看起來就像這樣。

jQuery(function($){ 
    //Initialise 
    iPhoneAnimation.init(); 

    //Mouse down bind move event 
    $(".content-box").bind("mousedown", function(e){ 
      $(this).bind("mousemove", iPhoneAnimation.moveInfo); 
      $(this).addClass("unselectable"); // <-- ADD THIS 
    }); 

    //Unbind mouse event 
    $(".content-box").bind("mouseup", function(e){ 
     var $this = $(this); 

     $this.unbind("mousemove", iPhoneAnimation.moveInfo); 
     //Animate the panel 
     iPhoneAnimation.panelAnimate($this); 
     //Reset the private var 
     iPhoneAnimation.resetVars(); 

     $(this).removeClass("unselectable"); // <-- AND ADD THIS 
    }); 
}); 

禁用徘徊,你需要解除綁定的mousedown這樣的事件:

$(this).unbind('mouseenter mouseleave'); 

然後再重新綁定他們mouseup如上。

+0

也做到了,謝謝! – Wesley

2
document.onmousemove = function(ev) 
{ 
    ev.preventDefault(); 
    /* 
    move it 
    */ 
} 
+0

這對我有效,謝謝! –

0

我將完成Icchanobot的回答多一個行:

-ms-user-select : none 

,使其與Internet Explorer上工作11/-