Yes we are! You're not only talking about the low percentage of browsers with JS off, but more important mobile browsers which don't have full support for javascript. That's a big market.
Besides that, using pure CSS is faster, simpler, less prone to errors and follows the unobtrusive principles. cheers, - ricardo On Mar 2, 3:38 am, expresso <dschin...@gmail.com> wrote: > Another thing I don't get is why everyone says JavaScript is not ideal. I > mean are we all really still worrying about users not having JS turned on in > the year 2009 when almost half the sites or more have JS reliant controls > and functions on the page? > > > > expresso wrote: > > > Thanks much for clarifying..! > > > mkmanning wrote: > > >> Since it's not a regex, it doesn't matter for the substring if > >> it's .asp or .aspx (or .as or .a for that matter). Any of those will > >> do. > > >> On Mar 1, 10:17 pm, expresso <dschin...@gmail.com> wrote: > >>> I see now. Yea, strip out the .aspx (asp is classic, nobody uses that > >>> anymore) > > >>> then take the page name and set the css to whatever element that has > >>> that ID > >>> as the page name's CSS. > > >>> thought about that, and to me that's the best way to to it if going the > >>> javaScript route. thanks a lot! > > >>> mkmanning wrote: > > >>> > When a user clicks a hyperlink, a new page loads and the code example > >>> > I gave executes -- on the new page ondomready. It never executed on > >>> > the click. That's why it's extracting the pathname from the location > >>> > object. > > >>> > On Mar 1, 10:05 pm, expresso <dschin...@gmail.com> wrote: > >>> >> I'm saying this: > > >>> >> 1) User clicks a hyperlink, it calls that javascript method which > >>> sets > >>> >> some > >>> >> css class > >>> >> 2) user is redirected to whatever page that hyperlink represented > >>> >> 3) you just lost the css that you changed when the user clicked the > >>> >> hyperlink > > >>> >> mkmanning wrote: > > >>> >> > I'm not sure what you mean by losing the CSS value? If you load a > >>> new > >>> >> > page, the CSS loads (preferably in an external stylesheet), and the > >>> >> > JavaScript executes ondomready (the JavaScript would have to be on > >>> >> > every page, or preferably included in an external file also). From > >>> >> > your example markup, each page has it's own unique pathname, so why > >>> >> > would you 'send' something in the querystring as opposed to the > >>> >> > suggested solution? > > >>> >> > By 'subtext' I assume you mean subnavigation; that can be handled > >>> the > >>> >> > same way. > > >>> >> > On Mar 1, 8:17 pm, expresso <dschin...@gmail.com> wrote: > >>> >> >> Problem with the JavaScript is that you loose the css value after > >>> >> you're > >>> >> >> redirected to whatever page. You'd have to obviously have to > >>> either > >>> >> do > >>> >> >> some > >>> >> >> if statements to check which .aspx page y ou went to or send the > >>> id of > >>> >> >> the > >>> >> >> anchor over in a querystring then grab it in JavaScript to set it > >>> >> again > >>> >> >> once > >>> >> >> you get to that page or else you loose the css that you set due to > >>> >> >> redirect > >>> >> >> oviously. > > >>> >> >> mkmanning wrote: > > >>> >> >> > You can do still do it with asp: > > >>> >http://stackoverflow.com/questions/188124/programmatic-solution-to-ch... > > >>> >> >> > Or if you really want to use JavasScript, the same solution > >>> above > >>> >> >> > applies: > > >>> >> >> > var pathname = window.location.pathname; > >>> >> >> > pathname = pathname.substring(pathname.lastIndexOf('/') > >>> >> >> > +1,pathname.indexOf('.asp')) > >>> >> >> > $('body').addClass(pathname); > > >>> >> >> > On Mar 1, 5:47 pm, expresso <dschin...@gmail.com> wrote: > >>> >> >> >> But I'm using a asp.net master page and inheriting it's body. > >>> so > >>> >> my > >>> >> >> >> pages > >>> >> >> >> only will have one global body tag. > > >>> >> >> >> mkmanning wrote: > > >>> >> >> >> > Unless your only option is to resort to JavaScript, this is > >>> >> >> something > >>> >> >> >> > you could do with CSS alone, if you put an id or class on the > >>> >> body > >>> >> >> tag > >>> >> >> >> > for each page and just rely on the CSS hierarchy to change > >>> the > >>> >> style > >>> >> >> >> > for each list item. It also has the advantage of working > >>> >> >> immediately, > >>> >> >> >> > instead of waiting for domready for example, and even works > >>> when > >>> >> >> >> > script is disabled, and can reduce code complexity. > > >>> >> >> >> > CSS: > >>> >> >> >> > body.home ul li.home, > >>> >> >> >> > body.about ul li.about, > >>> >> >> >> > body.contact ul li.contact { > >>> >> >> >> > color:red; > >>> >> >> >> > } > > >>> >> >> >> > HTML: > > >>> >> >> >> > <body class="about"> > > >>> >> >> >> > <div id="menu"> > >>> >> >> >> > <ul> > >>> >> >> >> > <li class="home"> default.aspx home </li> > >>> >> >> >> > <li class="about"> about.aspx about </li> > >>> >> >> >> > <li class="contact"> contact.aspx contact </li> > >>> >> >> >> > </ul> > >>> >> >> >> > </div> > > >>> >> >> >> > On Mar 1, 4:53 pm, expresso <dschin...@gmail.com> wrote: > >>> >> >> >> >> I'm trying to do something simple but this is my first stab > >>> at > >>> >> >> doing > >>> >> >> >> this > >>> >> >> >> >> in > >>> >> >> >> >> JQuery. > > >>> >> >> >> >> <div id="menu"> > >>> >> >> >> >> <ul> > >>> >> >> >> >> <li class="current_page_item"> > >>> >> >> >> default.aspx > >>> >> >> >> >> home </li> > >>> >> >> >> >> <li> about.aspx about </li> > >>> >> >> >> >> <li> contact.aspx contact </li> > >>> >> >> >> >> </ul> > >>> >> >> >> >> </div> > > >>> >> >> >> >> based on the page, change the css. So like doing a > >>> >> window.location > >>> >> >> >> and > >>> >> >> >> >> then > >>> >> >> >> >> parse out the url to the page then check. If it's the > >>> >> about.aspx I > >>> >> >> >> need > >>> >> >> >> >> to > >>> >> >> >> >> change the li item's css. > >>> >> >> >> >> -- > >>> >> >> >> >> View this message in > > >>> context:http://www.nabble.com/Change-CSS-depending-on-page-you%27re-on-tp2228... > >>> >> >> >> >> Sent from the jQuery General Discussion mailing list archive > >>> at > >>> >> >> >> >> Nabble.com. > > >>> >> >> >> -- > >>> >> >> >> View this message in > > >>> context:http://www.nabble.com/Change-CSS-depending-on-page-you%27re-on-tp2228... > >>> >> >> >> Sent from the jQuery General Discussion mailing list archive at > >>> >> >> >> Nabble.com. > > >>> >> >> -- > >>> >> >> View this message in > > >>> context:http://www.nabble.com/Change-CSS-depending-on-page-you%27re-on-tp2228... > >>> >> >> Sent from the jQuery General Discussion mailing list archive at > >>> >> >> Nabble.com. > > >>> >> -- > >>> >> View this message in > > >>> context:http://www.nabble.com/Change-CSS-depending-on-page-you%27re-on-tp2228... > >>> >> Sent from the jQuery General Discussion mailing list archive at > >>> >> Nabble.com. > > >>> -- > >>> View this message in > >>> context:http://www.nabble.com/Change-CSS-depending-on-page-you%27re-on-tp2228... > >>> Sent from the jQuery General Discussion mailing list archive at > >>> Nabble.com. > > -- > View this message in > context:http://www.nabble.com/Change-CSS-depending-on-page-you%27re-on-tp2228... > Sent from the jQuery General Discussion mailing list archive at Nabble.com.