473,326 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Image trails script in Firefox

KeredDrahcir
426 256MB
I have been given a script that will make the cursor work a bit like a comet, however the code deosn't work in Firefox. It has coditional statements which apply only to IE or NS.
I've tried the remove the IE conditions so that it runs that part of the code reguardless of the browser but it still doesn't work. I was wondering if someone could have a look at the code, and tell me what to do to it to make it work across multiple borwsers but mainly in Firefox.
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript">
  2.  
  3. //Comment trail script- By Kurt (kurt.grigg@virgin.net)
  4. //Script featured on Dynamic Drive
  5. //Visit http://www.dynamicdrive.com for this script and more
  6.  
  7. colours=new Array('#ff0000','#00ff00','#ffffff','#ff00ff','#ffa500','#ffff00','#00ff00','#ffffff','ff00ff')
  8. n = 10;
  9. y = 0;
  10. x = 0;
  11. n6=(document.getElementById&&!document.all);
  12. ns=(document.layers);
  13. ie=(document.all);
  14. d=(ns||ie)?'document.':'document.getElementById("';
  15. a=(ns||n6)?'':'all.';
  16. n6r=(n6)?'")':'';
  17. s=(ns)?'':'.style';
  18. if (ns){
  19. for (i = 0; i < n; i++)
  20. document.write('<layer name="dots'+i+'" top=0 left=0 width='+i/2+' height='+i/2+' bgcolor=#ff0000></layer>');
  21. }
  22. if (ie)
  23. document.write('<div id="con" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
  24. if (ie||n6){
  25. for (i = 0; i < n; i++)
  26. document.write('<div id="dots'+i+'" style="position:absolute;top:0px;left:0px;width:'+i/2+'px;height:'+i/2+'px;background:#ff0000;font-size:'+i/2+'"></div>');
  27. }
  28. if (ie)
  29. document.write('</div></div>');
  30. (ns||n6)?window.captureEvents(Event.MOUSEMOVE):0;
  31. function Mouse(evnt){
  32. y = (ns||n6)?evnt.pageY+4 - window.pageYOffset:event.y+4;
  33. x = (ns||n6)?evnt.pageX+1:event.x+1;
  34. }
  35. (ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse;
  36. function animate(){
  37. o=(ns||n6)?window.pageYOffset:0;
  38. if (ie)con.style.top=document.body.scrollTop;
  39. for (i = 0; i < n; i++){
  40. var temp1 = eval(d+a+"dots"+i+n6r+s);
  41.  
  42. randcolours = colours[Math.floor(Math.random()*colours.length)];
  43. (ns)?temp1.bgColor = randcolours:temp1.background = randcolours; 
  44. if (i < n-1){
  45.  var temp2 = eval(d+a+"dots"+(i+1)+n6r+s);
  46.  temp1.top = parseInt(temp2.top);
  47.  temp1.left = parseInt(temp2.left);
  48.  } 
  49. else{
  50.  temp1.top = y+o;
  51.  temp1.left = x;
  52.  }
  53. }
  54. setTimeout("animate()",10);
  55. }
  56. animate();
  57. // -->
  58. </script>
Any help would be much appriciated.
Jul 17 '11 #1
2 1721
acoder
16,027 Expert Mod 8TB
That code looks ancient!

First of all, get rid of all the NS code (unless you want to support NS4 for some very strange, unfathomable reason).

Then make the code access elements using document.getElementById().

Look at the common events code for cross-browser compatibility which should be easy enough to integrate.

Add units to top/left, e.g. "px".

That should point you in the right direction. Also, check the error console to see what else needs fixing.

Alternatively, scrap it altogether and find a modern script that's written using document.getElementById() as standard.
Jul 19 '11 #2
KeredDrahcir
426 256MB
Thanks. I'll give that a go. I have noticed to age of the code. I'll let you know how I get on.
Jul 19 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jason Brown | last post by:
I've seen a few out there, ranging from free to $150. I was looking for a recommendation for an image ranking script, like the one at http://www.ratepic.com. You have 10 radio buttons for quick...
6
by: bissatch | last post by:
Hi, I am using the following code to generate images online: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta...
5
by: William Starr Moake | last post by:
I want to adapt the following alert script into an insert image dialog in my WYSIWYG editor, but I can't get it to write an image tag correctly. <head> <script> function getImageDims(imgurl)...
3
by: jon | last post by:
Hello, I've had long standing code that runs in IE, that I'm testing with firefox unsuccessfully now. The problem seems to be that images that I dynamically create don't fire their onload event...
1
by: loupet | last post by:
Hello all I am new here and this is my first post. I have tried several javascripts to preview an image on a web page using the "input type=file" to Browse and preview the image. Using IE...
1
by: chris1606 | last post by:
This script floats one image over another (to conterract transparency). It works fine in Opera and Internet Explorer, but the image won't move in firefox. Any ideas how I can get it to work please? ...
7
tolkienarda
by: tolkienarda | last post by:
hi all I am using a php script to try to upload images to my database. i know i am connecting to my database because the image title is being wirtten to the database. but the image isn't example:...
1
by: bn4 | last post by:
I have been trying to modify a script that i had working in the past but have lost.. ORIGINAL URL: http://www.thescripts.com/forum/thread147097.html STEPS: I want it to do the following:...
3
by: Noorain | last post by:
Sir i want to resize image. Following script working in my local server. But This coding doesn't work in php 2.6.0. please help me <form action="<?php echo $_server; ?>" method="post"...
9
by: neovantage | last post by:
Hey geeks, I am using a script PHP Thumbnailer which resize image at run time. But it is not working in my case as i have integrated that script by studying it's documentation. Here is the URL...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.