Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Mouseover/Java Question

Reply
Thread Tools

Mouseover/Java Question

 
 
William Hughes
Guest
Posts: n/a
 
      05-29-2005
Situation:

I am using the following Javascript - based on Mike Cullen's MouseOver Button
Wizard ( http://www.mobw.net ) - to animate my site's navigation buttons:

<HEAD>

<script language="JavaScript">
var browser = '';
var version = '';
var entrance = '';
var cond = '';
// BROWSER
if (browser == ''){
if (navigator.appName.indexOf('Microsoft') != -1)
browser = 'IE'
else if (navigator.appName.indexOf('Netscape') != -1)
browser = 'Netscape'
else browser = 'NN';
}
// VERSION?
if (version == ''){
version= navigator.appVersion;
paren = version.indexOf('(');
whole_version = navigator.appVersion.substring(0,paren-1);
version = parseInt(whole_version);
}
// BROWSER & VERSION
if (browser == 'IE' && version >= 4) entrance = 'yes';
if (browser == 'IE' && version < 4) entrance = 'no';
if (browser == 'Netscape' && version >= 2.02) entrance = 'yes';
if (browser == 'Netscape' && version < 2.02) entrance = 'no';
if (entrance=='yes'){
name0a=new Image;name0a.src="./img/btn-top.bmp";
name0b=new Image;name0b.src="./img/btn-top-m.bmp";
name0c=new Image;name0c.src="./img/btn-top-o.bmp";

[... (16 other button definitions deleted)]

name17a=new Image;name17a.src="./img/btn-online.bmp";
name17b=new Image;name17b.src="./img/btn-online-m.bmp";
name17c=new Image;name17c.src="./img/btn-online-o.bmp";
}
function lighten(imgName) {
if (entrance == 'yes'){
imgOn = eval(imgName + 'b.src');
document[imgName].src = imgOn;
}
}
function darken(imgName) {
if (entrance == 'yes'){
imgOff = eval(imgName + 'a.src');
document[imgName].src = imgOff;
}
}
function darken2(imgName) {
if (entrance == 'yes'){
imgClick = eval(imgName + 'c.src');
document[imgName].src = imgClick;
}
}
</script>

</HEAD>

Within my pages, I use the following:

<BODY>

<br><br>
<center>
<!--Button Number 16-->
<a href="print.htm" target="_self" onmouseover="lighten('name15');
window.status='Go to the Print References page'; return true"
onmouseout="darken('name15'); window.status=''; return true"
onmousedown="darken2('name15'); window.status='Loading...'; return true"
onmouseup="darken('name15')"><img src="./img/btn-print.bmp" name="name15"
alt="Click button to go to the Print References page" border="0"></a>
<!--Button Number 17-->
<a href="video.htm" target="_self" onmouseover="lighten('name16');
window.status='Go to the Video References page'; return true"
onmouseout="darken('name16'); window.status=''; return true"
onmousedown="darken2('name16'); window.status='Loading...'; return true"
onmouseup="darken('name16')"><img src="./img/btn-video.bmp" name="name16"
alt="Click button to go to the Video References page" border="0"></a>
<!--Button Number 18-->
<a href="websites.htm" target="_self" onmouseover="lighten('name17');
window.status='Go to the Online References page'; return true"
onmouseout="darken('name17'); window.status=''; return true"
onmousedown="darken2('name17'); window.status='Loading...'; return true"
onmouseup="darken('name17')"><img src="./img/btn-online.bmp" name="name17"
alt="Click button to go to the Online References page" border="0"></a>
</center>

</BODY>

Both code sections are loaded with #INCLUDE statements.

Problem:

If I use the same button more than once in the body of the page, only the first
instance is animated; the subsequent uses are not, although they are functional.
What am I doing wrong?

Also, I am considering eliminating the ONMOUSEOUT statements. If I undertand the
function correctly, this will cause the ONMOUSEOVER and/or ONMOUSEDOWN text to
remain in the status bar. Is this correct?


 
Reply With Quote
 
 
 
 
David Dorward
Guest
Posts: n/a
 
      05-29-2005
William Hughes wrote:

> Situation:
>
> I am using the following Javascript


Your subject line talks about Java. Java and JavaScript have about as much
in common as Car and Carpet.

> <script language="JavaScript">


Missing required type attribute.

> if (navigator.appName.indexOf('Microsoft') != -1)
> else if (navigator.appName.indexOf('Netscape') != -1)


User agent string detection instead of object detection with no provision
for most modern browsers.

It is not a good script. I strongly suggest you ditch it.

> <br><br>


Use margins, not multiple hard line breaks.

> <center>


Deprecated. Use CSS.

> <!--Button Number 16-->
> <a href="print.htm" target="_self" onmouseover="lighten('name15');
> window.status='Go to the Print References page'; return true"


Most browsers let users block mucking about with the status bar - and with
good reason - its annoying and hides useful information from the user. I
suggest you get rid of that. Consider the title attribute for advistory
information.

> onmouseup="darken('name15')"><img src="./img/btn-print.bmp" name="name15"


..bmp files are highly inappropriate for use on the web. Try PNG, JPEG or
GIF.

> alt="Click button to go to the Print References page" border="0"></a>


The alt attribute is supposed to be a text replacement for the image, not a
tooltip. See my previous reference to the title attribute and try:

alt="Print References"

> <!--Button Number 17-->
> <a href="video.htm"


There is a distinct lack of anything between the links, this can cause it to
be difficult to tell where one link ends and the next starts (especially in
text only browsers). Try marking up the list of links as a list.

http://css.maxdesign.com.au/listamatic/

> Both code sections are loaded with #INCLUDE statements.


I'd suggest using <script src="..." ...></script> for including the
JavaScript. That will let the user cache it between pages and save
bandwidth (yours and theirs).

> If I use the same button more than once in the body of the page, only the
> first instance is animated; the subsequent uses are not, although they are
> functional. What am I doing wrong?


Probably having two elements with the same name and trying to reference them
by it.

> Also, I am considering eliminating the ONMOUSEOUT statements. If I
> undertand the function correctly, this will cause the ONMOUSEOVER and/or
> ONMOUSEDOWN text to remain in the status bar. Is this correct?


Try it and see.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
 
Reply With Quote
 
 
 
 
William Hughes
Guest
Posts: n/a
 
      05-29-2005
On Sun, 29 May 2005 14:09:15 +0100, in alt.html David Dorward
<> wrote:
> William Hughes wrote:
>
> > Situation:
> >
> > I am using the following Javascript

>
> Your subject line talks about Java. Java and JavaScript have about as much
> in common as Car and Carpet.


Sorry; wasn't aware of the difference.

> > <script language="JavaScript">

>
> Missing required type attribute.


Had that elsewhere.

> > if (navigator.appName.indexOf('Microsoft') != -1)
> > else if (navigator.appName.indexOf('Netscape') != -1)

>
> User agent string detection instead of object detection with no provision
> for most modern browsers.


???

> Most browsers let users block mucking about with the status bar - and with
> good reason - its annoying and hides useful information from the user. I
> suggest you get rid of that. Consider the title attribute for advistory
> information.


Done.

> > onmouseup="darken('name15')"><img src="./img/btn-print.bmp" name="name15"

>
> .bmp files are highly inappropriate for use on the web. Try PNG, JPEG or
> GIF.


The bitmaps were small, @2k each.

> There is a distinct lack of anything between the links, this can cause it to
> be difficult to tell where one link ends and the next starts (especially in
> text only browsers). Try marking up the list of links as a list.
>
> http://css.maxdesign.com.au/listamatic/


Nice. Very nice. I've fiddled with one of the examples and come up with
something that works better than the Javascript version I had... which pretty
much renders my earlier Javascript and your objections to it irrelevant.

The changes also reduced the filesize of each page considerably.


 
Reply With Quote
 
David Dorward
Guest
Posts: n/a
 
      05-29-2005
William Hughes wrote:

>> > if (navigator.appName.indexOf('Microsoft') != -1)
>> > else if (navigator.appName.indexOf('Netscape') != -1)

>>
>> User agent string detection instead of object detection with no provision
>> for most modern browsers.

>
> ???


http://jibbering.com/faq/#FAQ4_26

>> .bmp files are highly inappropriate for use on the web. Try PNG, JPEG or
>> GIF.


> The bitmaps were small, @2k each.


File size is not the only consideration, support for rendering such images
is weaker too.

>> http://css.maxdesign.com.au/listamatic/

>
> Nice. Very nice. <snip>
> The changes also reduced the filesize of each page considerably.


Fantastic.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
 
Reply With Quote
 
William Hughes
Guest
Posts: n/a
 
      05-30-2005
On Sun, 29 May 2005 22:28:26 +0100, in alt.html David Dorward
<> wrote:
> William Hughes wrote:


> >> http://css.maxdesign.com.au/listamatic/

> >
> > Nice. Very nice. <snip>
> > The changes also reduced the filesize of each page considerably.

>
> Fantastic.


Danke. Now if I could just find a way to put all the overhead from several dozen
iterations of

<img src="./img/st-sunk.gif"
alt=" (Lost in battle) "
align=middle
hspace=5
title="Ship sunk due to enemy action, including scuttling due to battle damage"
>


into CSS, I'd be a happy camper. Maybe I'll just have to wait for CSS3...


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57