View Full Version : autoclick script
mbzbugsy
01-17-2006, 09:25 PM
Hi everyone, im a noob when it comes to javascript. I need a script that automaticly clicks a specific link in a page on page load. This I need to sett a link element attribute from a to a:visited. If you have other suggestions please let me know. Thanks for reading. :)
... how about defining a different class for that link that has the properties you want?
mbzbugsy
01-18-2006, 01:30 AM
Thank you for your answer, I have tested what you suggested, didnt work for me. I have five links and the css is like this:
#team-nav a {
display: block;
padding-top:5px;
height:19px;
width:288px;
border-bottom:#cccccc 1px dotted;
background:#FFFFFF;
}
#team-nav a, #team-nav a:link, #team-nav a:visited {
text-decoration:none;
color:#5da4c3;
}
#team-nav a:hover {
text-decoration:underline;
color:#74bfe0;
background:#f1f1e3;
}
#team-nav a:active {
text-decoration:none;
color:#4a4a4a;
background:#f1f1e3;
}
Now if i set a different class for the first link like :
.active a { background:#f1f1e3; }
the background color wont change from #f1f1e3 to #FFFFFF. The links are:
<ul>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
<li><a href="#">Link 5</a></li>
</ul>
Anyway, what im trying to say is that i wanted to first link be as visited on page load. I thought that a javascript could make the first link clicked and set it as active. Any ideas?, thanks for reading.
Sorry, did you say you wanted it to appear visited or active?
the background color wont change from #f1f1e3 to #FFFFFF.I should hope not. You're trying to set the default #ffffff to #f1f1e3 on visit, not the other way around.
mbzbugsy
01-18-2006, 07:36 PM
Sorry im not clear. I wanted it to appear as active.
What I think is happening here is that the a:link you've specified overrides the style. Try something like:
a.preactive, a.preactive:link { background:#f1f1e3; }
<ul>
<li><a href="#" class="preactive">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
<li><a href="#">Link 5</a></li>
</ul>
mbzbugsy
01-18-2006, 09:22 PM
Right, but a:active will only remain active provided that the user clicks the link i want to be active on pageload. I need the link to act as a sort of breadcrumb to indicate where the user is at. thanks for reading.
The code I posted above won't actually make your link use a:active; instead, it will apply a different class you can use to make it look like it's active. This isn't constrained by clicking or not.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.