I'm using JavaScript to see if the current page's URL matches a particular sub directory structure. For example, if the URL is:
Code:
http://www.dynamicdrive.com/dynamicindex12/
I'm looking for:
where D is any number.
If a match is found, I dynamically write out a CSS code that applies a unique style to the CSS id with the matched number. The end result is:
Code:
var ddcurpageurl=window.location.toString() //current page url
var testre=/dynamicindex(\d+)/i
if (ddcurpageurl.match && ddcurpageurl.match(testre)!=null){
var catid="#c"+ddcurpageurl.match(testre)[1]
document.write('<style type="text/css">')
document.write(catid+" a{ color: black; background: #F0F0F0}")
document.write('<\/style>')
This works great in my case, but depending on the complexity of your URLs as far as being able to discern if a URL belongs to a specific category, it may not be feasible. FYI this script also contains a similar feature to highlight the current tab if the page's URL matches one of the tab's.
Bookmarks