Solved

href is not taking a page

Posted on 2011-09-22
10
329 Views
Last Modified: 2012-05-12
Hi,

I have a menu with button that when user click on it changes from image1 to image2.  I am having problem with the href it is not going to an page.  I am not sure what I am doing wrong.

here's my code.


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

//clicked images
var clk = new Array("images/BThome2.gif","images/BTMyAcc2.gif","images/BTPostAd2.gif","images/BTSearch2.gif",
"images/BTChat2.gif","images/BTHelp2.gif","images/BTContactUs2.gif");

//original images
var orig = new Array("images/BThome1.gif","images/BTMyAcc1.gif","images/BTPostAd1.gif","images/BTSearch1.gif",
"images/BTChat1.gif","images/BTHelp1.gif","images/BTContactUs1.gif");

function clicked(num) {
    document.images["img"+num].src=clk[num];
    for (i=0; i<7; i++){
        if (i != num) {
            document.images["img"+i].src = orig[i];
        }
    }
}
//-->
</script>



<img href="home.cfm" src="images/BThome1.gif" alt="" border="0" name="img0" onclick="clicked(0);">
<img href="MyAcc.cfm" src="images/BTMyAcc1.gif" alt="" border="0" name="img1"onclick="clicked(1)" >
<img href="PostAd.cfm" src="images/BTPostAd1.gif" alt="" border="0" name="img2"onclick="clicked(2)" >
<img href="Search.cfm" src="images/BTSearch1.gif" alt="" border="0" name="img3"onclick="clicked(3)" >
<img href="Chat.cfm" src="images/BTChat1.gif" alt="" border="0" name="img4"onclick="clicked(4)" >
<img href="Help.cfm" src="images/BTHelp1.gif" alt="" border="0" name="img5"onclick="clicked(5)" >
<img href="contactus.cfm" src="images/BTContactUs1.gif" alt="" border="0" name="img6"onclick="clicked(6)" >

Open in new window

0
Comment
Question by:lulu50
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 5

Expert Comment

by:zvytas
ID: 36580567
<img> tag doesn't have a href attribute, hence it's ignored. What are you trying to achieve exactly? Clicking on the image should go to that URL or what?
0
 

Author Comment

by:lulu50
ID: 36580585
yes

 Clicking on the image should go to that URL or what?
0
 

Author Comment

by:lulu50
ID: 36580587
yes

 Clicking on the image should go to that URL?
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:lulu50
ID: 36580607

I have <img href="home.cfm"  ??

<img href="home.cfm" src="images/BThome1.gif" alt="" border="0" name="img0" onclick="clicked(0);">
0
 
LVL 5

Accepted Solution

by:
zvytas earned 500 total points
ID: 36580630
What you need is this:

<a href="home.cfm"><img src="images/BThome1.gif" alt="" border="0" name="img0"></a>
<a href="MyAcc.cfm"><img src="images/BTMyAcc1.gif" alt="" border="0" name="img1"></a>
<a href="PostAd.cfm"><img  src="images/BTPostAd1.gif" alt="" border="0" name="img2"></a>
<a href="Search.cfm"><img  src="images/BTSearch1.gif" alt="" border="0" name="img3"></a>
<a href="images/BTChat1.gif"><img href="Chat.cfm" alt="" border="0" name="img4"></a>
<a href="Help.cfm"><img src="images/BTHelp1.gif" alt="" border="0" name="img5"></a>
<a href="contactus.cfm"><img src="images/BTContactUs1.gif" alt="" border="0" name="img6"></a>

Open in new window


Your JavaScript that changes images does not make any sense, because you cannot redirect to another page AND change the image at the same time.
0
 

Author Comment

by:lulu50
ID: 36580821
Can you please, tell me how to fix it?

Do you know why I have spaces?

How can I remove my spaces?
Menu.gif
0
 
LVL 13

Expert Comment

by:haloexpertsexchange
ID: 36580866
What css is being applied to that area?
0
 

Author Closing Comment

by:lulu50
ID: 36580895
Thanks
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36581260
zvytas is right

replace : <img href="home.cfm" src="images/BThome1.gif" alt="" border="0" name="img0" onclick="clicked(0);">
by : <a href="home.cfm" onclick="clicked(0);"><img src="images/BThome1.gif" alt="" border="0" name="img0" /></a>

and so on
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36581267
lol, sorry I did not refreshed the page :))
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Jquery 7 33
list:contains ... search finds as it should but how could I get the number items found? 3 25
modify change color of text 9 37
HTML editor custom button 3 59
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question