473,320 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

To change the link color

hi to everybody,
am new to this forum..
am working with J2ee,i have a jsp page where i have
some links,i want to change the link color when it is active,and it has to
turn back to original color when the other link is active,
i tried with style sheets,when i click on the link its changing its color,but
when the form loads ,its turning back to the original color,i want the color
to stay even after the form loads.
can anybody help me out..
Mar 19 '07 #1
22 4657
hi to everybody,
am new to this forum..
am working with J2ee,i have a jsp page where i have
some links,i want to change the link color when it is click,and it has to
turn back to original color when the other link is clicked,
i tried with style sheets,when i click on the link its changing its color,but
when the form loads ,its turning back to the original color,i want the color
to stay even after the form loads.

can anybody help me out..

Thank you
Mar 19 '07 #2
r035198x
13,262 8TB
hi to everybody,
am new to this forum..
am working with J2ee,i have a jsp page where i have
some links,i want to change the link color when it is click,and it has to
turn back to original color when the other link is clicked,
i tried with style sheets,when i click on the link its changing its color,but
when the form loads ,its turning back to the original color,i want the color
to stay even after the form loads.

can anybody help me out..

Thank you
How did you write your CSS. Post the code for it using code tags.
Mar 19 '07 #3
acoder
16,027 Expert Mod 8TB
Show your code please.
Mar 19 '07 #4
AricC
1,892 Expert 1GB
hi to everybody,
am new to this forum..
am working with J2ee,i have a jsp page where i have
some links,i want to change the link color when it is click,and it has to
turn back to original color when the other link is clicked,
i tried with style sheets,when i click on the link its changing its color,but
when the form loads ,its turning back to the original color,i want the color
to stay even after the form loads.

can anybody help me out..

Thank you
Here is how to handle link colors with CSS
Mar 19 '07 #5
Show your code please.
[HTML]<%@ taglib uri="/pages/tld/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/pages/tld/struts-html.tld" prefix="html" %>
<%@ taglib uri="/pages/tld/struts-logic.tld" prefix="logic" %>
<%@ page import="com.mass.drm.usermanagement.VO.UserVO" %>
<html>
<head>
<script>
function Changelink(id)
{
alert("inside changecolor...");
document.getElementById("id").style.color="blue";
}
</script>
</head>
<body onload="Open();">
<jsp:include page="/pages/jsp/logo.jsp"></jsp:include>
<table class="outer" cellspacing="0" cellpadding="0" border="0">
//Links
<td class="menulinks" align="left" style="padding-left: 5px">
<a class="dark" href="/drm/getuser.do">User Management</u></a>

<a class="dark" href="/drm/getConfig.do" id="CS" onclick="Changelink(this.id);"><u>Config Settings</u></a>

<A class="dark" href="/drm/getConfig.do"><u>Config Settings</u></A>
<td class="menulinks" align="left" style="padding-right: 50px">

<a class="dark" href="/drm/getUserProfile.do"><u>Profile</u></a>
<td class="menulinks" colspan="2" align="right">

<a class="dark" href="/drm/genpasswd.do"><u>Change Password</u></a>
</td>
</tr>
</table>
</body>
</html>[/HTML]


here i have given the code,
i tried with javascript,when i click the link
the color is changing,but the form corresponding
to the link loads,it turn back to the default color(default link color
is white).

thank you
Mar 20 '07 #6
acoder
16,027 Expert Mod 8TB
What do you mean by 'form corresponding to the link'? Does a new page load when the link is clicked?
Mar 20 '07 #7
What do you mean by 'form corresponding to the link'? Does a new page load when the link is clicked?
yes sir,new page will load when i click on the link
Mar 20 '07 #8
acoder
16,027 Expert Mod 8TB
Then obviously the formatting will be lost unless you code it to display the colour.

In your server-side code in "getConfig.do", change the colour of "Config Settings" to blue and likewise for all other pages/links.

If you want to do it via javascript, you can, if you, say, set the colour on page load.
Mar 20 '07 #9
Then obviously the formatting will be lost unless you code it to display the colour.

In your server-side code in "getConfig.do", change the colour of "Config Settings" to blue and likewise for all other pages/links.

If you want to do it via javascript, you can, if you, say, set the colour on page load.
i dont have more idea about setting the link color inside
server side code,am new to this,can you give
me the idea of how to set the link color?
am using struts.

it would be very helpful,thank you
Mar 21 '07 #10
How did you write your CSS. Post the code for it using code tags.
A:link {
color: white;
text-decoration: none;
}

A:visited {
color: white;
text-decoration: none;
}

A:hover {
color: #828282;
text-decoration: none;
}
A:active {
color: blue;
text-decoration: none;
}

its my style sheet..
i made the active link color as blue,but
when i click on the link,after the page loads corresponding to the link,
it turns back to the original color(white).
i want this to remain even after the page loads.
have i done anything wrong in my style sheet?
plz help me out..
Mar 21 '07 #11
Here is how to handle link colors with CSS
if i make use of stylesheet
with a:visited color as some color
all the visited link will change to that color.
i want the link color to be changed only for the link
i click,and if i click on the another link the previous link
should change to the default color.
because i have 3 ,4 links on the same page.

thanks for your help.
Mar 21 '07 #12
acoder
16,027 Expert Mod 8TB
i dont have more idea about setting the link color inside
server side code,am new to this,can you give
me the idea of how to set the link color?
am using struts.

it would be very helpful,thank you
The colour changing is with style/js, but the checking (if any) is done with the JSP. If you're not going to perform any checking, but manually alter the colours of the links, then some simple style setting will suffice.

In config.do, you can manually set the style to a blue colour, e.g. for this:
[HTML]<a class="dark" href="/drm/getConfig.do" id="CS" onclick="Changelink(this.id);"><u>Config Settings</u></a>[/HTML] add this style setting:
Expand|Select|Wrap|Line Numbers
  1. #CS { color:blue; }
Mar 21 '07 #13
drhowarddrfine
7,435 Expert 4TB
I misunderstood this post. What you are trying to do can't be done using CSS. You need to do that with your Java code so I would ask this question on that board, or I can move this thread there for you.
Mar 21 '07 #14
I misunderstood this post. What you are trying to do can't be done using CSS. You need to do that with your Java code so I would ask this question on that board, or I can move this thread there for you.
ok
it would be very helpful,thankyou
Mar 21 '07 #15
hello everybody,
am new to this forum..
am working with J2ee,i have a jsp page(using struts) where i have
some links,i want to change the link color when it is clicked,and has to
turn back to original color when the other link is clicked,
i tried with style sheets,when i click on the link color is changing,but
when the newpage loads,its turn back to the original color,
i want the color to stay even after the form loads.
can it be done with javascript?
i dont have more idea about it..
can anybody help me out..

any help would be grateful..
Thank you
Mar 21 '07 #16
r035198x
13,262 8TB
hello everybody,
am new to this forum..
am working with J2ee,i have a jsp page(using struts) where i have
some links,i want to change the link color when it is clicked,and has to
turn back to original color when the other link is clicked,
i tried with style sheets,when i click on the link color is changing,but
when the newpage loads,its turn back to the original color,
i want the color to stay even after the form loads.
can it be done with javascript?
i dont have more idea about it..
can anybody help me out..

any help would be grateful..
Thank you
I'm going to copy you over to the Javascript forum!
Mar 21 '07 #17
acoder
16,027 Expert Mod 8TB
Hmm... this is gonna look messy, but I'm going to have to merge the two threads.
Mar 21 '07 #18
AricC
1,892 Expert 1GB
I'm still not really clear what it is that you are trying to do here.
Mar 22 '07 #19
I'm still not really clear what it is that you are trying to do here.
i have one jsp page,having 4 links in that page
when i click a link,the color of the link has to change
and the color should remain when the page corresponding
to the clicked link loads.

this is my actual requirement,any help would be greatful.
thank you
Mar 22 '07 #20
acoder
16,027 Expert Mod 8TB
i have one jsp page,having 4 links in that page
when i click a link,the color of the link has to change
and the color should remain when the page corresponding
to the clicked link loads.

this is my actual requirement,any help would be greatful.
thank you
Did you try out what I suggested above in this post?
Mar 22 '07 #21
Did you try out what I suggested above in this post?
i didnot get that #CS ,is that the id what am using for the link
or is it in javascript?
i tried to specify that inside script.
please correct me if i have done anything wrong.
Mar 22 '07 #22
acoder
16,027 Expert Mod 8TB
i didnot get that #CS ,is that the id what am using for the link
or is it in javascript?
i tried to specify that inside script.
please correct me if i have done anything wrong.
Yes, that's the id for the link, but it's not javascript. It should be in your stylesheet.
Mar 22 '07 #23

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Matt Adams | last post by:
As well known I could specify the text color in the body tag like: <BODY TEXT=WHITE LINK=WHITE VLINK=RED ALINK=WHITE> What I want to achieve now is that always (!) the text of the last visited...
14
by: Reply Via Newsgroup | last post by:
Folks, Say I have a table, ten columns, ten rows - Each with a word in it. I want to change the values of some/all of the cells in the table via a hyperlink. How do I reference each cell and...
5
by: Matt | last post by:
I created 3 hyperlinks, when the user click each link, it will change the color of the text of a link. For example, when user clicks Link1, text Link1 will become red color, but Link2 and Link3...
0
by: Andrea | last post by:
Hi everyone. I'm working on a navigation menu (in a frameset) that I want to set the "active" link to black (the link that corresponds to the page displayed in the right side of the frame) to...
18
by: Jan Tuxen | last post by:
Jakob Nielsen in his most recent Alertbox (http://www.useit.com/alertbox/20040503.html) tells web authors to change the color of visited links. I agree to his purpose: Help users understand...
9
by: michael | last post by:
I have many links on a page, but for example sake, these two: <a href="bla1.html" id="link1">bla1</a> <a href="bla1.html" id="link2">bla1</a> I use a Javascript function to change the link...
2
by: deko | last post by:
I'm trying to change the font style of a link when that link is clicked. But the link (sometimes) includes a named anchor. So I need to test for a given named anchor and apply style changes if...
2
by: chris_culley | last post by:
Hi there, I've got a gif with (highly) irregular shapes (lots of jigsaw pieces) that I want to map so that each piece is a link... The pieces are currently just a frame drawing, but as they...
5
by: _Who | last post by:
I spent all day yesterday trying different things. Something has happened so I can't change font size. I have a table and in the first cell I have only text. I tried using the cell's Style...
6
by: gavy7210 | last post by:
hello i am using struts 1.2,Eclipse Platform Version: 3.4.2,mySql 5.0.1,jdk 1.5.. i have a login form(jsp) in which a user logs in,in case he doesnt enter his username and/or password an error...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.