Connecting Tech Pros Worldwide Forums | Help | Site Map

Need help with javascript links

Newbie
 
Join Date: May 2006
Posts: 1
#1: May 21 '06
Hi, I've been using a javascript script to create a dragon that flies across the page. Anyways, I'd like to make it so when you click the dragon it takes you to a new page. Was wondering if anyone could help me out here.

Below is the complete script.
Expand|Select|Wrap|Line Numbers
  1. <SCRIPT language="JavaScript1.2">
  2.  
  3.  
  4. var cursorpath="http://i68.photobucket.com/albums/i9/worklog_halcyon/Misc/pet1_lohi_dog.png"
  5.  
  6.  
  7. if (document.layers)
  8. {document.write("<LAYER NAME='PoInTeRs' LEFT=10 TOP=10><img src='"+cursorpath+"' width=60 height=66></LAYER>")}
  9. else if (document.all){document.write("<div id='pOiNtErS' style='position:absolute;top:10px;left:10px;width:60px;height:66px;z-index:100'><img src='"+cursorpath+"' width=60 height=66></div>")}
  10.  
  11. count=-1;                                                     
  12. move=1;
  13.  
  14. function Curve(){
  15. abc=new Array(0,1,1,1,2,3,4,0,6,-1,-1,-1,-2,-3,-4,0,-6)
  16. for (i=0; i < abc.length; i++)
  17. {var C=Math.round(Math.random()*[i])}
  18. howbend=abc[C];
  19. setTimeout('Curve()',1900);
  20. return howbend;
  21. }
  22. ypos=10;
  23. xpos=10;
  24.  
  25. degree = 60;
  26. function MoveRandom(){
  27. PathBend=degree+=howbend;//ok!
  28. y = 4*Math.sin(PathBend*Math.PI/180);
  29. x = 6*Math.cos(PathBend*Math.PI/180);
  30. if (document.layers){
  31. ypos+=y;
  32. xpos+=x;
  33. document.PoInTeRs.top=ypos+window.pageYOffset;
  34. document.PoInTeRs.left=xpos+window.pageXOffset;
  35. }
  36. else if (document.all){
  37. ypos+=y;
  38. xpos+=x;
  39. document.all.pOiNtErS.style.top=ypos+document.body.scrollTop;
  40. document.all.pOiNtErS.style.left=xpos+document.body.scrollLeft;
  41. }
  42. T=setTimeout('MoveRandom()',50);
  43. }
  44. function edges(){
  45. if (document.layers){
  46. if (document.PoInTeRs.left >= window.innerWidth-40+window.pageXOffset)degree=Math.round(Math.random()*45+157.5);
  47. if (document.PoInTeRs.top >= window.innerHeight-30+window.pageYOffset)degree=Math.round(Math.random()*45-112.5);
  48. if (document.PoInTeRs.top <= 2+window.pageYOffset) degree = Math.round(Math.random()*45+67.5);//OK!
  49. if (document.PoInTeRs.left <= 2+window.pageXOffset) degree = Math.round(Math.random()*45-22.5);//OK!
  50. }
  51. else if (document.all)
  52. {
  53. if (document.all.pOiNtErS.style.pixelLeft >= document.body.offsetWidth-45+document.body.scrollLeft)degree=Math.round(Math.random()*45+157.5);
  54. if (document.all.pOiNtErS.style.pixelTop >= document.body.offsetHeight-35+document.body.scrollTop)degree=Math.round(Math.random()*45-112.5);
  55. if (document.all.pOiNtErS.style.pixelTop <= 2+document.body.scrollTop) degree = Math.round(Math.random()*45+67.5);//OK!
  56. if (document.all.pOiNtErS.style.pixelLeft <= 2+document.body.scrollLeft) degree = Math.round(Math.random()*45-22.5);//OK!
  57. }
  58. setTimeout('edges()',100);
  59. }
  60. function starteffect(){
  61. Curve();
  62. MoveRandom();// onUnload="opener.gO()"
  63. edges();
  64. }
  65.  
  66. if (document.all||document.layers)
  67. window.onload=starteffect
  68. </script>

Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,185
#2: May 22 '06

re: Need help with javascript links


Change this

[html]<img src='"+cursorpath+"' width=60 height=66>[/html]

to

[html]<a href="[NextPage]"><img border="0" src='"+cursorpath+"' width=60 height=66></a>[/html]
in 2 places
Reply