Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't get this script working

Status
Not open for further replies.

dh20

Programmer
May 15, 2000
10
GB
Could some one please help me. I can't get this simple rollover script&nbsp;&nbsp;working. I would be very grateful if someone could point out where i'm going wrong. This is the Code.<br><br>&lt;html&gt;<br><br>&lt;head&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;Cool Image Swapper (RollOver)&lt;/title&gt;<br><br>&lt;script language=&quot;Javascript&quot;&gt;<br><br>// Check for Browser:<br>browserName = navigator.appName;<br>browserVer = parseInt(navigator.appVersion);<br>if (browserName == &quot;Netscape&quot; && browserVer &gt;= 3) version =&quot;1&quot;;<br>else if (browserName == &quot;Microsoft Internet Explorer&quot; && browserVer &gt;= &quot;4&quot; version = &quot;1&quot;;<br>else version =&quot;2&quot;;<br><br>// Now for the Images:<br>if(version == &quot;1&quot;)<br>{<br><br>anistatic1 = new Image(124,16);<br>anistatic1.src = &quot;not.gif&quot;;<br><br>anistatic2 = new Image(124,16);<br>anistatic2.src = &quot;turning.gif&quot;;<br><br>}<br><br>function ImageSwapper(imgDocID,imgObjName) {<br>if (Version == &quot;1&quot;) {<br>document.images
.src = eval(imgObjName + &quot;.src&quot;)<br>}<br>}<br><br>&lt;/script&gt;<br><br>&lt;/head&gt;<br><br>&lt;body&gt;<br><br>&lt;a HREF=&quot;<A HREF=" TARGET="_new"> <br>onMouseOut=&quot;ImageSwapper('ISwapper','anistatic1')&quot;&gt;<br><br>&lt;img Name=&quot;ISwapper&quot; SRC=&quot;not.gif&quot; border=&quot;0&quot; WIDTH=&quot;124&quot; HEIGHT=&quot;16&quot;&gt;&lt;/a&gt;<br><br>&lt;/body<br>&lt;/html&gt;<br><br><br>Thanks in advance.<br><br>
 
---&gt; if your browser is NOT netscape with a version &gt;= 3, it is NORMAL that your script doesn't work !!! (because you only do things if version==1)<br>---&gt; you miss one ) here :<br>else if (browserName == &quot;Microsoft Internet Explorer&quot; && browserVer &gt;= &quot;4&quot;<b><font color=red>)</font></b> version = &quot;1&quot;;<br>else version =&quot;2&quot;;<br>---&gt; why don't you set version as an integer ?? (version=1 and if (version==1) and browserVer&gt;4 and ...) <p> <br><a href=mailto:miss_lezard@bigfoot.com>miss_lezard@bigfoot.com</a><br><a href= > </a><br>
 
You have to remember I'm a real beginner, this is my first script. I don't fully understand the workings of the language yet. Also I have Internet Explorer 5. I get errors on line 12,41 and 42.
 
<br>did you add the &quot;)&quot; ??<br><br>you don't show the line numbers ;) <br>but i'll try to comment the code for you so at least you understand what you do :<br><br>// Check for Browser:<br>this part actually says : <br>if your browser name is netscape and its version greater than 3, set the version variable to 1<br>if your browser name is explorer and its version greater than 4, set the version variable to 1 also<br>if it's any other browser or version, set the version variable to 2<br><br>// Now for the Images:<br>this part defines the images src <br>ONLY if version=1 (read upper that means : if your browser name is explorer and its version greater than 4 or if your browser name is netscape and its version greater than 3)<br><br><br>now, here's the function you actually call when you click on your link - imgDocID is where in your html code the img will b replaced and imgObjName is the name of the img that will replace the previous one<br>it does it again only if version=1<br><br>function ImageSwapper(imgDocID,imgObjName) {<br>if (Version == &quot;1&quot;) {<br><font color=red>alert(document.images
.src)</font> &lt;--- add this line and tell me if it shows 'undefined' <br>...<br>&nbsp;}<br>}<br><br>-----------<br><br><br><br> <p> <br><a href=mailto:miss_lezard@bigfoot.com>miss_lezard@bigfoot.com</a><br><a href= > </a><br>
 
I'd suggest learning a language before using it. <A HREF=" TARGET="_new"> has some great tutorials, including JavaScript. Find out what you can, then come back. <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence.
 
hey liam!&nbsp;&nbsp;don't be so poopie.&nbsp;&nbsp;maybe dh20 has to write this script now...for his job or something.&nbsp;&nbsp;i'm a newby too.&nbsp;&nbsp;yet the scripts i am working on are for my job.&nbsp;&nbsp;besides, if were already knew all of that stuff we wouldn't need you now. would we?:) <p>bobbie<br><a href=mailto:thibault@hotbot.com>thibault@hotbot.com</a><br><a href= </a><br>
 
*smile* understandable.. the Webmonkey tutorials will just give you a start, they won't tell you everything- but what they will give you that's necessary is the ability to understand people's responses. If you don't know the first thing about a language, you're not asking for help- you're asking for a fix. You can only accept help if you know what the help is. So reading those tutorials is a great place to start (that's where I started) so you can better understand responses that people will give you.<br><br>And I've always been a purist, call me a poopie if you want :eek:) just that so many people steal scripts without knowing what they do, then get upset when they don't work. Know what I mean? :eek:) <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top