a:active long URL problem

freecrm

New Member
Messages
629
Reaction score
0
Points
0
Hi all..

It's been a while since I've posted, but I have an interesting problem.

Very simply, I have a menu

menu, ul, li, span etc etc. and want to add an a:active attribute to the css.

BUT - many of the URL's are dynamic and include variable data for $_GET requests.

How do I strip out the unecessary stuff after the ? and then how do I get the a:active attribute working on the result.

I just can't get my head around this at all..

Rich
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
a:active is used when the link is activated by mouse click. You can define it in a stylesheet, but I don't think you can do it inline (ie <a style="....)

Code:
a:active {
....
}

You can remove everything after the question mark using strstr():

Code:
strstr($url, '?', true); //returns everything before ? is found in $url (true means before, false means including and after)
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
Thanks my friend..

I already knew about the css definition, but the strstr function I'd missed and was trying a combination of others...

Now this is the tricky bit..

If a link (menu) has a static url address and you visit a dynamic address (say /forums?id=1), I know I can replace the value for the url, but that doesn't actually replace the url itself.

ie, I can add a value $shorturl = strstr(current url) etc. but that does'nt change the current url to $shorturl.

Even if this were possible, I need the dynamic url to get the page to work....

So...

How do I maintain my dynamic url and get the static a href link in the menu to recognise when it's active??

(surely a css a:active will only recognise an exact match?)

Is this clearer (it's not to me :D)

Rich
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
The :active class isn't dependent on the value of element attributes, including linked URIs. The attribute value would matter only if you were using an attribute selector, such as [href^=/forums] or [href$=id=1] (note: using "^=" and "$=" in attribute selectors is CSS3).

In short, just use a:active in you selector and don't worry about the URI.
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
The :active class isn't dependent on the value of element attributes, including linked URIs. The attribute value would matter only if you were using an attribute selector, such as [href^=/forums] or [href$=id=1] (note: using "^=" and "$=" in attribute selectors is CSS3).

In short, just use a:active in you selector and don't worry about the URI.
I was wondering what the url parameters had to do with css.
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
Aaaarrgghhh - this explains the confusion...

My fault...

I meant a:current, not a:active!!!

Sorry for the wasted time... this issue is still unresolved though.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
There is no ":current" pseudo-class in CSS1, 2.1 or 3. Are you using jQuery?
 
Last edited:
Top