Possible to restyle link target?

This is a discussion on "Possible to restyle link target?" within the JavaScript Forum section. This forum, and the thread "Possible to restyle link target? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 4th, 2007, 14:43
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Possible to restyle link target?

Is it possible to restyle a link target (using javascript - I can do the css but support is spotty) when the link is clicked?
Reply With Quote

  #2 (permalink)  
Old Feb 4th, 2007, 22:53
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Possible to restyle link target?

I don't understand...
Reply With Quote
  #3 (permalink)  
Old Feb 4th, 2007, 22:59
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Possible to restyle link target?

Actually, do you mean like the CSS :active? If so, you can use JavaScript. I haven't checked this, but it should work:

Code: Select all
var Links = {
    init: function() {
        var anchors = document.getElementsByTagName("a");
        for(var i = 0; i < anchors.length; i++) {
            anchors[i].onmousedown = Links.down;
            anchors[i].onmouseup = Links.out;
        }
    },
    down: function() {
        this.className += " active";
    },
    out: function() {
        this.className = this.className.replace(" active", "");
    }
}
window.onload = Links.init;
Then make an .active class in your CSS for that.
Reply With Quote
  #4 (permalink)  
Old Feb 5th, 2007, 11:30
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Possible to restyle link target?

Sorry, I'll restate. I have a local link on a page: <a href="#nekkidgirl">.

When a user clicks the link and goes to <a name="nekkidgirl">something</a>, I would like for "something" to become boldface or "color:red;" or whatever.

I have a great mass of verbiage, and I would like to be able to pick out a phrase by using the link. The solution may lie in the fact that the url changes when the link is clicked. Would it be possible to have a style conditional on the url changing?

If you want to see what I'm working on:
http://www.dhreport.com/test_interactive/exercise.php

PS Thanks for the reply, I stuck it in just for fun and it works fine -- just doesn't do anything I need

Last edited by masonbarge; Feb 5th, 2007 at 11:41.
Reply With Quote
  #5 (permalink)  
Old Feb 5th, 2007, 21:53
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Possible to restyle link target?

Have you thought about using JavaScript to extract the anchor from the url when the page loads and then use that piece of information to alter the style for the element whose id or name matches.
Reply With Quote
  #6 (permalink)  
Old Feb 6th, 2007, 11:27
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Possible to restyle link target?

Could I tie that to a click on the link? Guess I'd better brush up on my js skilz.
Reply With Quote
  #7 (permalink)  
Old Feb 6th, 2007, 22:19
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Possible to restyle link target?

Um I was thinking about it. You'll need to have an onclick event that styles the link clicked and then unstyles the others. Does that make sense?
Reply With Quote
  #8 (permalink)  
Old Feb 7th, 2007, 10:20
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Possible to restyle link target?

I'm not sure I've been clear.

I have a long list of radio buttons -- 250+ in three columns --generated from a db. I have links at the top of the page to about 12 of them. When one of these links is clicked, unfortunately you are in a screen full of radio buttons and labels.

What I'd like to do is highlight the button/label that is the target of the link, so that if somebody is trying to find it and clicks a link, they can find it easier.

I could easily give every one of them a different class with the same style properties, then change the properties of that class. Or, since it's in xhtml, I could use the id property to style them.

I think I could do this code in php (of course, it wouldn't work); but my js skilz r l4m3z (: I need to be upping my js anyway, and this is a good project, but I haven't a clue where to start.

Last edited by masonbarge; Feb 7th, 2007 at 10:22.
Reply With Quote
Reply

Tags
link, target

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Target _blank Jack Franklin Web Page Design 12 Oct 12th, 2007 09:55
Target Window Name jayaramgussy Web Page Design 9 Sep 20th, 2007 22:44
Validating target Lchad Web Page Design 16 Jan 18th, 2007 13:36
XHTML Target JacobHaug Web Page Design 7 Jan 4th, 2007 11:55
Frameset target help please charter Flash & Multimedia Forum 4 Mar 28th, 2004 10:05


All times are GMT. The time now is 10:08.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43