|
|
 |
Re: FN-FORUM: Javascript problem (another one!)
date posted 9th August 2003 16:21
Hi Luke,
thanks again, this is really helpful, I had been writing some 'if's' late
last night but it was too late and they ended up getting far too
complicated! This would explain why I missed the extra quotes too, I had
seen those lines of code too often!
I shall try and make it work now!
Cheers
Nita ;o)
----- Original Message -----
From: "Luke Perman" [EMAIL REMOVED]
To: [EMAIL REMOVED]
Sent: Saturday, August 09, 2003 12:17 PM
Subject: Re: FN-FORUM: Javascript problem (another one!)
>
> hi nita,
>
> everything looks fine with your code, and yes, the onClick version you
> have below would work - the only thing you have missed are some
> quotemarks around the name of the layer you are trying to show/hide...
> so your piece of code should read:
>
> swapOut('linktwo'); swapOut('linkone');">Link 4
>
> where the DIVs are named as such in the CSS i.e. #linkone { blah blah }
>
> and then called in the HTML like something in
> here
>
> if you wanted to further optimise the code, you could create a variable
> called 'layerFlag' each time the function is called, so that you don't
> have to cycle through all the layers to turn them off each time, the
> code would always know the last layer that was made visible.
>
> this would work like this (assuming that the layer 'linkone' was
> visible on loading the page, but it doesn't really matter, you just
> have to set the variable up with something before using it :-)
>
>
>
> var layerFlag = 'linkone';
>
> function swapIt(thisone) {
>
> if (thisone == layerFlag) return;
>
> document.all[layerFlag].style.visibility = 'hidden';
> document.all[thisone].style.visibility = 'visible';
>
> layerFlag = thisone;
>
> }
>
>
>
>
> and then in your HTML you would simply need:
>
> Link 4
>
>
> i have added the line: if (thisone == layerFlag)... this just quits
> the user from the function if they happen to click a link to a layer
> that is already visible, so that they don't see a flash as the same
> layer disappears and reappears again!
>
>
> HTH!
> luke
>
>
>
> On Friday, August 8, 2003, at 09:04 PM, Nita wrote:
>
> > Hi Luke, I was trying out the script you sent and I'm not sure if I'm
> > using
> > it properly...
> >
> >
> > I've put the function in and I have the following mouseovers and outs:
> >
> >
> > > onMouseout="swapOut(textrhs);
> > ">Introduction
> > > onMouseout="swapOut(linkone);
> > ">How does this on-line course work?
> > > onMouseout="swapOut(linktwo);">Registration Form
> > > onMouseout="swapOut(linkthree);">Study Plan
> > > onMouseout="swapOut(linkfour)">Link 4
> >
> > Each time I hover I get:
> >
> > document.all[...].style is null or not an object
> >
> > I'm afraid I can't see where I'm making a mistake....
> >
> > Also, I wanted to show the divs onClick - I was getting the same error
> > and
> > being diverted to my folder and it was bugging me so I changed it for
> > ease
> > of testing! But it also occured to me that I would need to swapout
> > each div
> > something like this:
> >
> > > swapOut(linktwo);
> > swapOut(linkone);">Link 4
> >
> > Would this make sense? I couldn't tell if it would have worked
> > because I
> > was getting the same error as above....
> >
> > Can you shed any light on it?
> >
> > Very much appreciated if you can!
> >
> > Nita
> > ;o)
>
>
> ==========
> fido.net are pleased to sponsor these Freelancers messages. For all
> your web hosting needs check out http://www.fido.net/ with hosting
> packages starting from just £46.95 a year including VAT.
> Free 0871 Fax2Email numbers also available online!
> http://www.fido.net/ - the internet made simple! - 0800 1072 666
>
> To advertise here: http://www.freelancers.net/advertising.html
>
> |
 |
|