Results 1 to 8 of 8

Thread: autoclick script

  1. #1
    Join Date
    Jan 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default autoclick script

    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.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    ... how about defining a different class for that link that has the properties you want?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Jan 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry im not clear. I wanted it to appear as active.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    What I think is happening here is that the a:link you've specified overrides the style. Try something like:
    Code:
    a.preactive, a.preactive:link { background:#f1f1e3; }
    Code:
    <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>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Jan 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •