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-tp22280342s27240p22282651.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to