473,666 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forcing an A:active status on a link via javascirpt

Hello.
I'm trying to solve a problem related to JS and CSS.
I produced an HTML page with several links and buttuns.
I then created a CSS file in order to display a yellow background when
a link is clicked by users.

UL.menu1 LI A:active{
BACKGROUND: yellow; COLOR: black

Naturally, having acted on the A:active property, when a link is
clicked, all the others lose the yellow background.
The fact is that my page have to reload frequently. The effect I'd like
to obtain is that, when the page reloads, the link that was 'active'
before reloading continued to show the yellow background.
Having the chance of retrieving the link ID, I tried to force this
status using a simple js line

activeLinkID.cl ick();

at the body onload event. The click was executed but the yellow
background did not appear.

Is there a way to force an 'active' status via JS on the link ?

I thank you in advance for any help.

Newcomsas

Jun 9 '06 #1
3 2208
MB
Having the chance of retrieving the link ID, I tried to force this
status using a simple js line

activeLinkID.cl ick();

at the body onload event. The click was executed but the yellow
background did not appear.


I would try:

document.getEle mentById(active LinkID).style.b ackgroundColor = "#ffff00";

Jun 9 '06 #2
Well, this was effectly the first solution I thought of. The fact is
that my page have several links; if you set directly the backgorund, it
remains shown even when you click on another link (so when the 'active'
status is passed to another <A HREF tag).
I frankly don't know how to 'tell' the first link to de-activate its
background when another is clicked :-(

Newcomsas


MB ha scritto:
Having the chance of retrieving the link ID, I tried to force this
status using a simple js line

activeLinkID.cl ick();

at the body onload event. The click was executed but the yellow
background did not appear.


I would try:

document.getEle mentById(active LinkID).style.b ackgroundColor = "#ffff00";


Jun 9 '06 #3
MB

"Newcomsas" <ne*******@hotm ail.com> skrev i meddelandet
news:11******** **************@ y43g2000cwc.goo glegroups.com.. .
Well, this was effectly the first solution I thought of. The fact is
that my page have several links; if you set directly the backgorund, it
remains shown even when you click on another link (so when the 'active'
status is passed to another <A HREF tag).
I frankly don't know how to 'tell' the first link to de-activate its
background when another is clicked :-(

Newcomsas
If I understand you correctly, a click on any of those links doesn't cause
the page to reload, but rather some javascript function is called, is that
right? Because then you can store the ID of the link you set the background
color for, in a variable and start by resetting the background color for the
previously clicked link:

if (lastClickedID != "")
document.getEle mentById(lastCl ickedID).style. backgroundColor = "";
document.getEle mentById(active LinkID).style.b ackgroundColor = "#ffff00";
lastClickedID = activeLinkID;

Also put this somewhere in the head of your document:
lastClickedID = "";
Otherwise you will get an error when 'if (lastClickedID != "")' runs,
because it would not have been set yet.

That would make sure the link color is only yellow on the link you just
clicked and not on any other link. But this will only work as long as the
page is not reloaded.


MB ha scritto:
> Having the chance of retrieving the link ID, I tried to force this
> status using a simple js line
>
> activeLinkID.cl ick();
>
> at the body onload event. The click was executed but the yellow
> background did not appear.


I would try:

document.getEle mentById(active LinkID).style.b ackgroundColor = "#ffff00";

Jun 9 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7551
by: William Park | last post by:
(Cross-posted because I use Mozilla Firefox, but I think it's also CSS issue.) Usually when I move mouse over a link, the URL is displayed at the bottom on "status line". On some website, however, this is surpressed. This is very annoying, because I can't find out the destination URL unless I click it. When I click it, the URL shows up as soon as mouse button is pressed. So, this is A:HOVER and A:ACTIVE related. At the moment, my...
36
3876
by: Peter Brause | last post by:
Hello, my stylesheet shows different colors for visited, active and hovered links. It works fine in IE 6, but in Opera 7 the color for the active link (red background) is never shown. How to explain this? Here is my code: (code optimization will be done later) 1. The HTML file <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head>
11
7912
by: Wilhelm Kutting | last post by:
Hi i got a problem running the active tag i use in my stylesheet definition #menu li a:active{ color: #8B008B; } What didt't work out Using
4
4500
by: Stephen Poley | last post by:
The issue of the focus pseudo-class came up a few weeks ago, and I finally got around to trying it out (better late than never ...) The recommended order given for the pseudo-classes is link, visited, focus, hover, active. However: - Mozilla doesn't seem to do anything with the active rule; - IE gets things wrong as usual: it uses the active rule for focus; it ignores the focus rule; - Opera ignores both focus and active rules and...
2
2540
by: Kelly | last post by:
I have a subform that display requisition information. One of the fields in the subform is a combo box that shows who requested the requisition. The users can change who requested the requisition and I would like to only have them be able to choose active employees. So, I have written the query for the rowsource for this combo box, which is based on an employees table, to look at all active employees and the employee that is currently...
1
2408
by: DaveF | last post by:
Is there a way to be able to check a url link to see if it is active or not? Example. I put urls to images in an Iframe on my site. If they change the url, It gives me an image not found error. I want to make a service that runs every 3 days to check theses links for validity? -- dave
9
5441
by: newcomsas | last post by:
Hello. I'm working on a problem related with CSS and javascript: I have got a link on a page and a stylesheet file that makes the background color change when users click on it. Is there anyone who knows if it is possible to 'force' via javascript a status A:active on a link ? I mean: is there a property of the style that can make the css believe a link was clicked when in reality it was not ?
8
8248
by: salad | last post by:
I was wondering how you handle active/inactive elements in a combo box. Let's say you have a combo box to select an employee. Joe Blow has been selected for many record however Joe has left the company and has been flagged inactive. If you have a filter on the rowsource like Where Active = True then Joe's name would not show up in the combo list. This would be fine if the combo is associated with a field that is null/0. It would not be...
0
65305
by: shorti | last post by:
We are running DB2 UDB 8.1 fp 14 on AIX using archival logging and online backups. I was running some disaster tests and found my database restore was not restoring to the latest active log. Online backup include logs. For this test I created a disaster where we lost the database about 30 minutes after the last backup. Current archive and active logs were saved off and I ran a Restore of the latest backup and rollforward to the end of...
0
8866
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8638
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7381
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6191
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4365
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1769
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.