Jump to content

highlight link


vj5

Recommended Posts

There is no such thing as alink or vlink attributed.You can use CSS to choose how a link looks after it's clicked:a:link {/* A normal link */color: blue;}a:visited {/* A visited link */color: purple;}a:hover {/* The mouse is over the link */color: #0099FF;}a:active {/* The mouse button is pressed on the link */color: red;}

Link to comment
Share on other sites

Hi, i would try something like this:

<a onclick="changeColor(this)" >take me there</a>in js:function changeColor(link){  link.style.color = "#FFFFFF";}

of course it would be better to have all the js inobtrusive, but ...

Link to comment
Share on other sites

There is no such thing as alink or vlink attributed.You can use CSS to choose how a link looks after it's clicked:a:link {/* A normal link */color: blue;}a:visited {/* A visited link */color: purple;}a:hover {/* The mouse is over the link */color: #0099FF;}a:active {/* The mouse button is pressed on the link */color: red;}
Instead of CSS , I gave it in the body of the page. Anyway, I want to change the color of the link when clicked and stay that color. Is it possible to do so?
Link to comment
Share on other sites

Yes, your question has been answered already by alexnofue.If you want to apply it to all the links of the document at once, you can have a code like this in the head of your document:

<script type="text/javascript">function changeColor(e) {  e = (e)?e:window.event;  e = (e.nodeType == 3)?e.parentNode:e;  link = (e.srcElement)e.srcElement:e.target;  link.style.color = "#FFFFFF";}window.onload = function() {  var A = document.getElementsByTagName("a");  for (var i=0;i<A.length;i++) {	A[i].onclick = changeColor;  }}</script>

Link to comment
Share on other sites

Yes, your question has been answered already by alexnofue.If you want to apply it to all the links of the document at once, you can have a code like this in the head of your document:
<script type="text/javascript">function changeColor(e) {  e = (e)?e:window.event;  e = (e.nodeType == 3)?e.parentNode:e;  link = (e.srcElement)e.srcElement:e.target;  link.style.color = "#FFFFFF";}window.onload = function() {  var A = document.getElementsByTagName("a");  for (var i=0;i<A.length;i++) {	A[i].onclick = changeColor;  }}</script>

I copied your code to my page. It gives errors. Its says that it needs an ; somewhere in the code. Right now, it is not doing anything.

Link to comment
Share on other sites

Hi, i would try something like this:
<a onclick="changeColor(this)" >take me there</a>in js:function changeColor(link){  link.style.color = "#FFFFFF";}

of course it would be better to have all the js inobtrusive, but ...

You code does only when clicked on the link, it shows the color then it goes off. I want the color to change .
Link to comment
Share on other sites

I fixed the error. When clicked on the link, it shows the color, then the color goes off. I want the color to be there , ie, changed. I am creating headers and each link is taking the user to a page. For example, if I have blue links, when click on it, it should turn red and stay red so it is understood that I am on that page.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...