2011-08-17 5 views
1

JavaScript는 컴퓨터에서는 실행되지만 iPad에서는 실행되지 않습니다. 다른 제스처가 있는지 확실하지 않습니다. 그러나 브라우저에서 항목을 터치하여 드래그하면 이동해야하지만 컴퓨터에서는 작동하지만 iPad에서는 전체 화면을 이동합니다. JavaScript로 제스처를 다시 작성해야합니까? 어떻게해야합니까?JavaScript는 컴퓨터에서 실행되지만, iPad에서는 실행되지 않습니다.

제스처는 iPad 용 컴퓨터에서 작동하는 것처럼 보이지 않습니다.

//global variables 
var obj,x,y,dx,dy; 
// set up draggable elements 
function Setup(){ 
    //exit if the browser doesn't support the DOM 
    if (!document.getElementsByTagName) return; 
    divs=document.getElementsByTagName("DIV"); 
    for (i=0; i<divs.length;i++){ 
     if (divs[i].className != "drag") continue; 
     //set event handler for each div with class="drag" 
     divs[i].onmousedown=Drag; 
    } 
} 
function Drag(e){ 
    //Start dragging an object 
    if (!e) var e = window.event; 
    //which object was clicked? 
    obj=(e.target) ? e.target: e.srcElement; 
    obj.style.borderColor="red"; 
    //calculate object offsets from mouse position 
    dx=x-obj.offsetLeft; 
    dy=y-obj.offsetTop; 
} 
function Move(e){ 
    //track mouse movements 
    if (!e) var e =window.event; 
    if (e.pageX){ 
     x=e.pageX; 
     y=e.pageY; 
    }else if (e.clientX){ 
     x = e.clientX; 
     y = e.clientY; 
    }else return; 
    if (obj){ 
     obj.style.left=x-dx; 
     obj.style.top=y-dy; 
    } 
} 
function Drop(){ 
    //let go! 
    if (!obj) return; 
    obj.style.borderColor="black"; 
    obj=false; 
} 
//Detect mouse movement 
document.onmousemove = Move; 
//drop current object on mouse up 
document.onmouseup = Drop; 
//set up when the page loads 
window.onload = Setup; 
+0

복제 코드 또는 URL을 게시 할 수 있습니까? –

답변

2

이것은 iPad/iPod Touch/iPhone/etc가 터치 인터페이스이기 때문에 발생합니다. 큰 페이지를 탐색하려면 화면을 터치하여 드래그 할 수 있어야합니다. vonconrad는 great explanation about this issue here입니다.

관련 문제