codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Convert script to NS6 compatible - Please Help!  hello_kitty_girl at 10:36 on Friday, February 18, 2005
 

Hi, I'm trying to convert the following to be compatible with the current version of Netscape/Mozilla - can anyone help? I would be very grateful:


var Ver4=parseInt(navigator.appVersion.charAt(0))>=4
var IE=navigator.appName.indexOf("Microsoft")!=-1
var Ver4=1
var IE=-1
//var IE=(navigator.appName.indexOf("Microsoft")!=-1) : (navigator.appName.indexOf("Netscape")!=-1
var al, imagesrc, ex=-32, ey=-32, x0=-32, y0=-32

function BewegeAlien()
{ // Neue Position des Alien berechnen
if (Math.abs(ex-x0)>=10) { x0+=Math.floor((ex-x0)*0.1) }
else if (ex!=x0) { x0+=Math.abs(ex-x0)/(ex-x0) }
if (Math.abs(ey-y0)>=10) { y0+=Math.floor((ey-y0)*0.1) }
else if (ey!=y0) { y0+=Math.abs(ey-y0)/(ey-y0) }

// entsprechende Grafik in Bezug zur Maus-Position waehlen
imagesrc=""
if ( (ex<x0) && ( (x0-ex) > Math.abs(y0-ey)/2 ) )
{ imagesrc="/forum/dog_l.gif"
if ( (x0-ex) < Math.abs(y0-ey)*2 )
{ if (ey<y0) imagesrc="/forum/dog_l.gif"
if (ey>y0) imagesrc="/forum/dog_l.gif"
}
}
if ( (ex>x0) && ( (ex-x0) > Math.abs(y0-ey)/2) )
{ imagesrc="/forum/dog_r.gif"
if ( (ex-x0) < Math.abs(y0-ey)*2 )
{ if (ey<y0) imagesrc="/forum/dog_r.gif"
if (ey>y0) imagesrc="/forum/dog_r.gif"
}
}
if (imagesrc=="")
{ if (ey<y0) imagesrc="/forum/dog_r.gif"
if (ey>y0) imagesrc="/forum/dog_r.gif"
if ((ex==x0)&&(ey==y0)) imagesrc="/forum/dog_w.gif"
}

// Grafik und Position setzen
if (Ver4)
{ if (!IE)
{ document.AlienLayer.document.images.alien.src=imagesrc }
else document.all.AlienLayer.document.images.alien.src=imagesrc
}
al.left=x0-32
al.top=y0

setTimeout("BewegeAlien();",100)
}

function MeinMausEvent(e)
{ // Position des Maus-Cursors ermitteln
if (Ver4)
{ if (!IE)
{ ex=e.pageX
ey=e.pageY }
else
{ ex=event.clientX + document.body.scrollLeft
ey=event.clientY + document.body.scrollTop }
}
}

function ScriptSetup()
{ // Alle Alien-Grafiken laden
isIm = (document.images) ? 1 : 0
if (isIm)
{ arImLoad = new Array
('dog_w','dog_l','dog_r')
arImList = new Array ()
for (counter in arImLoad)
{ arImList[counter] = new Image()
arImList[counter].src = arImLoad[counter] + '/forum/.gif'
}
}

// Globale Variablen setzen und Maus-Event initialisieren
if (Ver4)
{ if (!IE)
{ al=document.AlienLayer
document.captureEvents(Event.MOUSEMOVE)
}
else
{ al=document.all.AlienLayer.style }
document.onmousemove = MeinMausEvent
BewegeAlien()
}
}

function Copyright()
{ window.focus()
alert("Script by Stefan Kuhn, original cursor by Microsoft, altered by Dierk Luerbke") }

function ZeigeAlien()
{ // Setzen der Block-Level Container zur Anzeige der Grafiken
if(Ver4)
{ s ='<DIV STYLE="visibility:hidden"></DIV>'
s+='<DIV ID="AlienLayer" STYLE="position:absolute; '
s+='top:-32; left:-32; width:32; height:32">'
s+='<A HREF="javascript:Copyright();">'
s+='<IMG NAME="alien" SRC="/forum/dog_w.gif" border=0>'
s+='</A></DIV>'
document.writeln(s)
}
}

window.onload = ScriptSetup
ZeigeAlien()

<Added>

Sorry, you can disregard lines 3-5, they were not in the original code. oops.








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Line Printer Interface
•  import contacts of msn/yahoo
•  Call windows apps from web apps
•  Re: onmouseover change image and text
•  Re: ASP.NET web controls
•  netscape 6 browser problem
•  Re: Print .doc file from the website using System.Diagnostics.Process
•  Re: Print and print preview file on the website without using the File - Print on the IE
•  Re: JavaSript Problem In Mac Safari Browser


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005