Javascript Navigation

This is a discussion on "Javascript Navigation" within the JavaScript Forum section. This forum, and the thread "Javascript Navigation are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 13th, 2004, 08:11
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
Javascript Navigation

The navigation on my site consists of 5 images, each one has a rollover, when its clicked it changes the content of an iframe. I need to somehow make the image that is clicked stay highlighted (rolled-over) so that the user knows which section they clicked on, but i also need to make sure all the other rollovers work and the when a different image is clicked, the previous one returns to its normal state.

At the moment my links just look like this:

<img name=img1 src=img1.gif border=0 width=20 height=10>


Any ideas?

Thanks
Smokie

  #2 (permalink)  
Old Feb 13th, 2004, 09:36
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Smokie...

Use an onclick event to make the changes stay when you click it.
You'll need to use a javascript function to handle the rollovers and the click even and also
use a flag for the element to indicate if the element has been clicked.

If it has been clicked, then just dissallow the rollover events.
When a different element is clicked then obviously you cancel the flag on the previous element.

Well.... I know what I'm talking about anyway.

lol
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #3 (permalink)  
Old Feb 13th, 2004, 13:21
Up'n'Coming Member
Join Date: Oct 2003
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jamslam
Yea I understand you Rob, similar methods are used in a drop down menu...

I think that you need to create a variable, that holds the ID the button that has been clicked. Then when another one is clicked, you use that ID to set its image back to the regular state.

When I get home from school, I'll see if I can whip up a script to do all of this
  #4 (permalink)  
Old Feb 13th, 2004, 13:48
Up'n'Coming Member
Join Date: Oct 2003
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jamslam
alright nevermind, I just did it now in school...

Make sure to read the directions in the comments




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title> Javascript </title>

<script type="text/javascript">
<!--

// Use the following variables to easily change images.
// If you want unique images for each link, then just
// change the second argument (currently it's either
// "hoverImage" or "noHoverImage") to the file path
// that you want

// this variable holds the original state image...
noHoverImage = "images/button_bg.jpg";

// this variable holds the hover state image
hoverImage = "images/button_bgover.jpg";

// leave this variable alone
// it holds the ID of the image
// that was clicked
keepHover = null;

function changeImages(which,to) {
// if no dom.. return
if(!document.getElementById || keepHover == which) {
return false;
}

// get object
obj = document.getElementById(which);

obj.src = to;
}

function keepHoverState(which,to) {
// if no dom return
if(!document.getElementById) {
return false;
}

// get the old keepHover and change it back
if(keepHover != null) {
oldObj = document.getElementById(keepHover);

oldObj.src = noHoverImage;
}

// get object
obj = document.getElementById(which);

obj.src = to;

keepHover = which;
}

-->
</script>

</head>
<body>

[img]images/button_bg.jpg[/img]

[img]images/button_bg.jpg[/img]

[img]images/button_bg.jpg[/img]

[img]images/button_bg.jpg[/img]

[img]images/button_bg.jpg[/img]

</body>
</html>
  #5 (permalink)  
Old Feb 17th, 2004, 09:22
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
omg thanx jamslam!!!

perfect!
  #6 (permalink)  
Old Feb 17th, 2004, 13:26
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Hey smokie.... those avatars rock!!
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #7 (permalink)  
Old Feb 17th, 2004, 14:01
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
cheers dude, do you like my avatar randomiZOR!! [:P]
  #8 (permalink)  
Old Feb 18th, 2004, 10:39
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Yeah.... and I first thought our dynamic signatures feature was knackered.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #9 (permalink)  
Old Feb 24th, 2004, 15:33
Junior Member
Join Date: Feb 2004
Location: USA
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to taco
Damn i see why i am still learning html this whole topic confused me i will look into all this when i am ready and in my eyes i am not ready for all this but i would like to learn how to make it where i change the pages in an iframe without changing the frame page is there an easy way to do this in html using maybe some added script or am i gonna have to do double pages for easy iframe page i want to use?
  #10 (permalink)  
Old Feb 24th, 2004, 15:55
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
dude, some punctuation would be nice!!

you need to use a target on your links to change the iframe without changing the main page, like this:

a href=page.html target=iframeName
  #11 (permalink)  
Old Feb 24th, 2004, 16:09
Junior Member
Join Date: Feb 2004
Location: USA
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to taco
Sorry about the punctuation. Thanks a lot for the tip on the target i will try to work that into my site and see what i can come up with. I may mess it up so expect some more questions on this and thanks again it is very great of you guys to share you knowledge with all of us newbies
Closed Thread

Tags
javascript, navigation

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 On

Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript rollover navigation through css supbtsup JavaScript Forum 2 May 27th, 2008 02:56
javascript navigation buttercup JavaScript Forum 3 Jan 24th, 2008 10:22
Javascript navigation problems mikka23 JavaScript Forum 8 Sep 30th, 2007 12:22
Javascript Navigation Will Not Work With Firefox cpando1974 JavaScript Forum 2 Apr 1st, 2007 14:56
JavaScript Navigation II soda JavaScript Forum 3 Sep 29th, 2005 11:44


All times are GMT. The time now is 19:11.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

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