Welcome to WebmasterWorld Guest from 54.162.240.235

Forum Moderators: open

Message Too Old, No Replies

Javascript debug (probably easy)

changing the contents of a <div> but that's not the hard part...

     
8:10 am on Mar 11, 2002 (gmt 0)

10+ Year Member



dhdepot.htm (on the site in my profile) is the page in question

okay, the script is as follows:
//set up quote for now

var quotetouse="quote" ;
document.all.qlayer.innerHTML=quotetouse ;
var cat=99 ;

//end set up quote

//this func is called when user mouses over an image, as follows: onMouseOver="swapoutquote(1);"

function swapoutquote(cat) {
if (cat=1) {
desc="Category1desc"; }
if (cat=2) {
desc="Category2desc"; }
if (cat=3) {
desc="Category3desc"; }
if (cat=4) {
desc="Category4desc"; }
if (cat=5) {
desc="Category5desc"; }
if (cat=6) {
desc="Category6desc"; }
if (cat=7) {
desc="Category7desc"; }
if (cat=8) {
desc="Category8desc"; }
if (cat=9) {
desc="Category9desc"; }
if (cat=0) {
desc="Category0desc"; }
if (cat=99) {
desc="!!<br>Error!"; }

document.all.qlayer.innerHTML=desc;
}

function swapinquote() {
document.all.qlayer.innerHTML=quotetouse;
}

what it does is say "Error!" indicating that cat still equals 99? or is it just assigning desc to the last one? Cos before i added the '99' error checking it was setting desc to "Category0desc".

if you go to the link, the nav in question is the pic at left, but i only put the onMouseOver's on the top 2 slices so far.

thx for any help!
-dan

(edited by: tedster at 9:02 am (utc) on Mar. 11, 2002)

9:29 am on Mar 11, 2002 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Welcome to Webmaster World, dan2k

Looks to me like you need to edit the onMouseover function calls -- right now you still have some Dreamweaver code:

onMouseOver="MM_callJS('swapoutquote(1);')"

should probably be:
onMouseOver="swapoutquote(1)"

Also, be warned that there are several recent browsers that don't support onMouseover for image tags - better to put all your onMouseover calls in the anchor tag for cross-browser support.

8:58 am on Mar 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Another consideration when it comes to cross browser support is the innerHTML property.

It's actually doesn't exist. It's something that IE threw into the language and that later versions of Netscape picked up because of popular demand.

There are other ways of doing it, both for image mouseovers and for more in depth dynamic content.

The other benefit of using alternate methods is that they involve both the default text/code and the text/code that replaces it actually existing on the page (as far as a robot is concerned). Good for search engine indexing.

7:06 am on Mar 15, 2002 (gmt 0)

10+ Year Member



Did you spot it?

Every "if" condition is true except for this one: if (cat=0)

You're using the assignment operator "=". You should be using the comparison operator "==".

5:56 am on Mar 16, 2002 (gmt 0)

10+ Year Member



Thank you, Mike. I didn't notice that. It's been awhile since I borrowed that JavaScript book.

Thanks.

-Dan

Also, does anyone care to enlighten me as to the following:
(A) What Netscape compatibility can I expect for the innerHTML? As long as v6 is supported, it's good enough for the moment.
(B) What is a good way to do something like this which would be very cross-browser?

Thanks for your help,
Dan

6:56 am on Mar 16, 2002 (gmt 0)

10+ Year Member



After fixing that page and checking it out in Netscape, I see that it doesn't even work in Netscape 6.2.

Since the client I'm working on this for is a big Netscape fan, it should be changed, even though that particular effect is only secondary in nature. We're going to put the name of each category on the "over" version of each slice.

8:24 am on Mar 18, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



StickyMailed you other method.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month