2012-10-03 4 views
0

나는 커서 흔적을위한 다음과 같은 스크립트를 가지고있다. 그러나 커서 이미지는 페이지의 좌상단에 나타나고 커서 흔적으로 보이지 않는다? 무엇이 스크립트가 올바르게 작동하지 않게 할 수 있습니까? 나는에서이 스크립트를 복사 : 나는, 나는 또한 해제 시도 (내가 원래 이미지에 절대 경로를 사용) 이미지 경로를 편집 시도 http://www.dynamicdrive.com/dynamicindex13/trailer.htm자바 스크립트 커서

이전에 나는이 흔적

<script> 
/****************************************** 
* Cross browser cursor trailer script- By Brian Caputo ([email protected]) 
* Visit Dynamic Drive (http://www.dynamicdrive.com/) for full source code 
* Modified Dec 31st, 02' by DD. This notice must stay intact for use 
******************************************/ 

A=document.getElementById 
B=document.all; 
C=document.layers; 
T1=new Array("wp-content/uploads/2012/10/meerkat1.gif",77,39,"wp-content/uploads/2012/07/meerkat2.gif",77,39,"wp-content/uploads/2012/10/meerkat3.gif",77,39,"wp-content/uploads/2012/10/meerkat4.gif",77,39,"wp-content/uploads/2012/10/meerkat5.gif",77,39,"wp-content/uploads/2012/10/meerkat6.gif",77,39) 

var offsetx=15 //x offset of trail from mouse pointer 
var offsety=10 //y offset of trail from mouse pointer 

nos=parseInt(T1.length/3) 
rate=50 
ie5fix1=0; 
ie5fix2=0; 
rightedge=B? document.body.clientWidth-T1[1] : window.innerWidth-T1[1]-20 
bottomedge=B? document.body.scrollTop+document.body.clientHeight-T1[2] : window.pageYOffset+window.innerHeight-T1[2] 

for (i=0;i<nos;i++){ 
createContainer("CUR"+i,i*10,i*10,i*3+1,i*3+2,"","<img src='"+T1[i*3]+"' width="+T1[(i*3+1)]+" height="+T1[(i*3+2)]+" border=0>") 
} 

function createContainer(N,Xp,Yp,W,H,At,HT,Op,St){ 
with (document){ 
write((!A && !B) ? "<layer id='"+N+"' left="+Xp+" top="+Yp+" width="+W+" height="+H : "<div id='"+N+"'"+" style='position:absolute;left:"+Xp+"; top:"+Yp+"; width:"+W+"; height:"+H+"; "); 
if(St){ 
if (C) 
write(" style='"); 
write(St+";' ") 
} 
else write((A || B)?"'":""); 
write((At)? At+">" : ">"); 
write((HT) ? HT : ""); 
if (!Op) 
closeContainer(N) 
} 
} 

function closeContainer(){ 
document.write((A || B)?"</div>":"</layer>") 
} 

function getXpos(N){ 
if (A) 
return parseInt(document.getElementById(N).style.left) 
else if (B) 
return parseInt(B[N].style.left) 
else 
return C[N].left 
} 

function getYpos(N){ 
if (A) 
return parseInt(document.getElementById(N).style.top) 
else if (B) 
return parseInt(B[N].style.top) 
else 
return C[N].top 
} 

function moveContainer(N,DX,DY){ 
c=(A)? document.getElementById(N).style : (B)? B[N].style : (C)? C[N] : ""; 
if (!B){ 
rightedge=window.innerWidth-T1[1]-20 
bottomedge=window.pageYOffset+window.innerHeight-T1[2] 
} 
c.left=Math.min(rightedge, DX+offsetx); 
c.top=Math.min(bottomedge, DY+offsety); 
} 
function cycle(){ 
//if (IE5) 
if (document.all&&window.print){ 
ie5fix1=document.body.scrollLeft; 
ie5fix2=document.body.scrollTop; 
} 
for (i=0;i<(nos-1);i++){ 
moveContainer("CUR"+i,getXpos("CUR"+(i+1)),getYpos("CUR"+(i+1))) 
} 
} 

function newPos(e){ 
moveContainer("CUR"+(nos-1),(B)?event.clientX+ie5fix1:e.pageX+2,(B)?event.clientY+ie5fix2:e.pageY+2) 
} 

function getedgesIE(){ 
rightedge=document.body.clientWidth-T1[1] 
bottomedge=document.body.scrollHeight-T1[2] 
} 

if (B){ 
window.onload=getedgesIE 
window.onresize=getedgesIE 
} 

if(document.layers) 
document.captureEvents(Event.MOUSEMOVE) 
document.onmousemove=newPos 
setInterval("cycle()",rate) 
</script> 
에 사용 된 "플러그인"을 사용
+0

그 코드는 더 이상 존재하지 않는 브라우저를위한 참고 자료입니다. – epascarello

+0

"동적 드라이브"사이트는 피해야합니다. 코드 품질은 일반적으로 끔찍합니다. – Pointy

+0

답장을 보내 주셔서 감사합니다. 아무도 아마 좋은 품질의 코드를 제공하는 사이트에서 나에게 조언을 해줄 수 있습니까? :) – user1426583

답변

0

이렇게하면 이미지가 커서를 따라갑니다. 나는 원래 북마크 릿으로 사용 했으므로 모든 자바 스크립트입니다.

var hi = document.createElement("img"); 
var att = document.createAttribute("src"); 
var sty = document.createAttribute("style"); 
var alt = document.createAttribute("onclick"); 
var ide = document.createAttribute("id"); 
ide.value = "hi01";alt.value = "alert('Hi')"; 
att.value = "http://www.picgifs.com/clip-art/cartoons/pokemon/clip-art-pokemon-441770.jpg"; 
sty.value = "position: absolute;top: 0px;left: 0px;height: 100px;width: 100px;cursor:crosshair;"; 
hi.setAttributeNode(att); 
hi.setAttributeNode(alt); 
hi.setAttributeNode(sty); 
hi.setAttributeNode(ide);document.body.appendChild(hi); 
var scr = document.createElement("script"); 
var scratt = document.createAttribute("src"); 
scratt.value = "http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"; 
scr.setAttributeNode(scratt); 
document.body.appendChild(scr); 
$("body").mousemove(function(e){ 
    var a = e.pageX - 50; 
    var b = e.pageY - 50; 
    document.getElementById('hi01').style.left = a+'px'; 
    document.getElementById('hi01').style.top = b+'px'; 
}); 
관련 문제