University Crest

[wlug] javascript

 
wlug archive index About the wlug list Mailing lists home
To The University of Waikato HomepageWaikato Home > Waikato Mailing Lists > wlug Info > wlug archives
Haldor Riddering haldor@s...
Mon Feb 9 04:06:42 NZDT 2009


Glenn Stuart Morrissey wrote:
> hi there all
> 
> is anyone able to help me out with a bit of javascript code?
> On my webpage:gmorrissey.kol.co.nz I have a page called page_template.
> I have only uploaded the red and black images for the first two buttons
> (a blue and a red button for mouseover). I dont think I have quite got
> the code right as the buttons arent changing colour on mouseover.
> I had an online script that I used as a template, I seemed to have gone
> awry for some reason. Any tips appreciated.
> 
> Glenn.
> 
> _______________________________________________
> wlug mailing list | wlug@l...
> Unsubscribe: http://list.waikato.ac.nz/mailman/listinfo/wlug
> 

you could do it this way but not using your array:

<a href="mystory.html" onmouseover="mystory.src='images/mystory_down.png';"
onmouseout="mystory.src='images/mystory_up.png';">

<img src="images/mystory_up.png" width="100" height="50" border="0" 
alt="Move your mouse over me" name="mystory" />
</a>

using your code it needs tweaking:

<SCRIPT LANGUAGE = "JavaScript">
<!--

mystory_on=new Image;
mystory_on.src="./images/mystory_down.png";

mystory_off=new Image;
mystory_off.src="./images/mystory_up.png";
  -->

note the ; at end

then the body code:

<a href="mystory.html" OnMouseOut="document.mystory.src=mystory_off.src";
     OnMouseOver="document.mystory.src=mystory_on.src";>
     <img src="./images/mystory_up.png" name="mystory" width="100" 
height="50" border="1"></a>

added the document tag, and ; and also each image needs to be called 
something different. you had both the same name.
also you had a naming convention spelling mistake my_blog_on at top
and in the <a> tag you called it myblog_on. that is a leading cause of 
mistakes. use a single naming convention throughout your project and it 
need not happen again.

if you email me directly (haldor@z... I can send you the reworked file.

also I uploaded it to my site so you can check it out, along with 
comments in the html. http://www.zox.co.nz/glenn






More information about the wlug mailing list
NOTICE: This is an archive of a public mailing list. The University of Waikato is not responsible for its contents.

The University of Waikato - Te Whare Wananga o Waikato