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 colors:
document.getElementById("link1").style.color='lime '
document.getElementById("link2").style.color='lime '
Above works fine to change the 2 link colors to lime, but is there way to
dynamically change all links on a page, without a separate id for each
link, and without reloading the page with a new link style declaration? 9 3899
"michael" <no****@example.com> wrote in message
news:cb*************@news.t-online.com... 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 colors:
document.getElementById("link1").style.color='lime ' document.getElementById("link2").style.color='lime '
Above works fine to change the 2 link colors to lime, but is there way to dynamically change all links on a page, without a separate id for each link, and without reloading the page with a new link style declaration?
var links = document.getElementsByTagName("a");
Harlan Messinger wrote: var links = document.getElementsByTagName("a");
By the above I've got the variable "links" as an HTML object collection.
I suppose this is now a Javascript question; but how could I dynamically
change all link colors on the page from here?
Any further pointers would be much appreciated... Thanks.
In article <cb*************@news.t-online.com>, no****@example.com
says... Harlan Messinger wrote:
var links = document.getElementsByTagName("a");
By the above I've got the variable "links" as an HTML object collection. I suppose this is now a Javascript question; but how could I dynamically change all link colors on the page from here? Any further pointers would be much appreciated... Thanks.
Use a for loop on the collection.
> Use a for loop on the collection.
Does anyone have an example?
> Does anyone have an example?
.... found a solution:
links = document.getElementsByTagName("a");
for (var i=0;i<links.length;i++)
if (links[i].className=="link")
links[i].style.color = 'lime';
}
On Tue, 22 Jun 2004 18:13:43 +0200, michael <no****@example.com> wrote: 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 colors:
Why?
--
Rex
On Wed, 23 Jun 2004 07:51:05 +0200, michael <no****@example.com> wrote: Why?
Why not?
For starters, not all users have Javascript enabled. You can change link
colors in CSS, which is more widely trusted.
michael wrote: Use a for loop on the collection.
Does anyone have an example?
Please take it to comp.lang.javascript. But before posting a question,
check the archives. This has come up before. You might also consider
Google.
--
Brian (remove ".invalid" to email me) http://www.tsmchughs.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mat |
last post by:
How can I detect when a link has been clicked but the new page is
still in the process of loading? The document.location.href property
still displays the current location (understandably) not the...
|
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...
|
by: Richard Cornford |
last post by:
For the last couple of months I have been trying to get the next round
of updates to the FAQ underway and been being thwarted by a heavy
workload (the project I am working on has to be finished an...
|
by: Denny Schierz |
last post by:
hi,
i want to change my link colors in the p class="suchen":
That is my html:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//DE"...
|
by: Franklin |
last post by:
WITHOUT KNOWING ANYTHING ABOUT THE CURRENT COLORS, I want to swap the
foreground/background colors of a link when someone hovers over it. Is
this possible with HTML, CSS, DOM, & JavaScript? If...
|
by: menno.abbink |
last post by:
Hi All,
I'm asked to come up with a sollution for the following:
We are developing an application that will be displayed on a videowall
( at least 4000 x 2000 pixels) that will be used to...
|
by: hestres |
last post by:
Hello,
I'm working on some link styles for this page:
http://www.house.gov/velazquez/lh0205tres/reports.html
I want all the links to always display in red (#CC0000), but in IE6
and 7 they...
|
by: torquehero |
last post by:
hi,
I am working with dreamweaver MX 2004. The problem is with Link colors (text). In page properties I have specified the link color, visited links, active links as #000000 and rollover links as...
|
by: momee80 |
last post by:
Hi,
I'm encountering a problem with IE 7 that my visited links do not keep their colors changed when they are revisited. i.e, when I reload the page, the links should change their colors so that I...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |