[jQuery] Re: Change CSS depending on page you're on

2009-03-02 Thread expresso
True, but if you're not developing or care about the browsers on the phones at the moment then who cares. Obviously we are going to later on but for now, you don't have to necessarily target phones even if they are a bigger part of the picture. With that, I'm saying JS is not such an issue. r

[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread ricardobeat
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.

[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread expresso
Nice post! I'll try the body route like everyone else has Maujor wrote: > > > How about use the widely ways to achieve this? > > 1-) Via CSS > Assign an ID to the body element for each page, like: > , , > > and an ID for each menu item like: > > >default.aspx home >

[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread expresso
Sure, if the user has it turned off, they're just not going to see the nice highlighted selection on the menu items. But I bet you it's rare that we have to worry anymore about JS being turned off. If that were the case, JQuery and rest would be an "issue" today. expresso wrote: > > Another

[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread expresso
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 clari

[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread expresso
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 wrote: >> I see now.  Yea, strip out the .aspx (asp is classic, no

[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread mkmanning
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 wrote: > I see now.  Yea, strip out the .aspx (asp is classic, nobody uses that > anymore) > > then take the page name and set the

[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread expresso
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! mkmannin

[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread mkmanning
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 wrote: > I'm saying this: > > 1) User clicks a hyper

[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread expresso
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

[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread mkmanning
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

[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread expresso
Also when dealing with Subtext, it's not that simple, I'm trying to figure out how do that in Subtext...the example you spoke of but it's difficult, I need to figure out where I can do this since it's a bit complicated in how they are rending their user controls, default.aspx, etc. expresso wro

[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread expresso
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

[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread mkmanning
You can do still do it with asp: http://stackoverflow.com/questions/188124/programmatic-solution-to-change-navigation-id-to-highlight-current-page-asp-net Or if you really want to use JavasScript, the same solution above applies: var pathname = window.location.pathname; pathname = pathname.subst

[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread expresso
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

[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread Mauricio (Maujor) Samy Silva
How about use the widely ways to achieve this? 1-) Via CSS Assign an ID to the body element for each page, like: , , and an ID for each menu item like: home about contact And CSS selector for current page is: body#home li#ho a:link, body#about li#ab a:link, bod

[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread mkmanning
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