<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Automatically highlight current page in menu via Javascript</title> <atom:link href="http://www.richnetapps.com/automatically_highlight_current_page_in/feed/" rel="self" type="application/rss+xml" /><link>http://www.richnetapps.com/automatically_highlight_current_page_in/</link> <description>Internet Applications - Flash, Flex, Silverlight, JavaFX</description> <lastBuildDate>Sat, 06 Mar 2010 17:44:11 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>By: Juan</title><link>http://www.richnetapps.com/automatically_highlight_current_page_in/comment-page-1/#comment-643</link> <dc:creator>Juan</dc:creator> <pubDate>Tue, 09 Feb 2010 13:07:23 +0000</pubDate> <guid
isPermaLink="false">#comment-643</guid> <description>With regards to the question of whether I can highlight two different links on the same page, for example, if I have a main navigation call &quot;about us&quot; and a left navigation call &quot;vision and mission&quot;, how do I get both &quot;about us&quot; and &quot;vision and mission&quot; highlighted. Take it that &quot;aboutus.html&quot; and &quot;visionandmission.html&quot; are in the same folder? Thanks. :)</description> <content:encoded><![CDATA[<p>With regards to the question of whether I can highlight two different links on the same page, for example, if I have a main navigation call &#8220;about us&#8221; and a left navigation call &#8220;vision and mission&#8221;, how do I get both &#8220;about us&#8221; and &#8220;vision and mission&#8221; highlighted. Take it that &#8220;aboutus.html&#8221; and &#8220;visionandmission.html&#8221; are in the same folder? Thanks. <img
src='http://cdn.richnetapps.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: Juan</title><link>http://www.richnetapps.com/automatically_highlight_current_page_in/comment-page-1/#comment-640</link> <dc:creator>Juan</dc:creator> <pubDate>Mon, 01 Feb 2010 15:11:48 +0000</pubDate> <guid
isPermaLink="false">#comment-640</guid> <description>Thanks much for your code! :)</description> <content:encoded><![CDATA[<p>Thanks much for your code! <img
src='http://www.richnetapps.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: Chris Wheeler</title><link>http://www.richnetapps.com/automatically_highlight_current_page_in/comment-page-1/#comment-638</link> <dc:creator>Chris Wheeler</dc:creator> <pubDate>Sun, 31 Jan 2010 09:52:09 +0000</pubDate> <guid
isPermaLink="false">#comment-638</guid> <description>Thanks very much for this.  A great piece of code. I may modify it slightly for my use, but nevertheless it was a great help.</description> <content:encoded><![CDATA[<p>Thanks very much for this.  A great piece of code. I may modify it slightly for my use, but nevertheless it was a great help.</p> ]]></content:encoded> </item> <item><title>By: website development</title><link>http://www.richnetapps.com/automatically_highlight_current_page_in/comment-page-1/#comment-619</link> <dc:creator>website development</dc:creator> <pubDate>Thu, 14 Jan 2010 13:01:04 +0000</pubDate> <guid
isPermaLink="false">#comment-619</guid> <description>I am building a new website for commensus.co.uk and was looking for a similar solution. thanks a lot for this tutorial the CSS+Javascript solution rocks</description> <content:encoded><![CDATA[<p>I am building a new website for commensus.co.uk and was looking for a similar solution. thanks a lot for this tutorial the CSS+Javascript solution rocks</p> ]]></content:encoded> </item> <item><title>By: Armand Niculescu</title><link>http://www.richnetapps.com/automatically_highlight_current_page_in/comment-page-1/#comment-610</link> <dc:creator>Armand Niculescu</dc:creator> <pubDate>Tue, 22 Dec 2009 06:21:54 +0000</pubDate> <guid
isPermaLink="false">#comment-610</guid> <description>Tim,if you have a nested menu structure and want to highlight parent elements as well as children, eg:
&lt;pre&gt;&lt;code&gt;
&lt;ul&gt;&lt;br /&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Item 1&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Item 2&lt;/a&gt;&lt;br /&gt;
&lt;ul&gt;&lt;br /&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Item 2.1&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Item 2.2&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Item 2.3&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Item 3&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;
&lt;/ul&gt;
&lt;/code&gt;&lt;/pre&gt;
then, at line 16, you need to add
&lt;pre&gt;&lt;code&gt;
arr[i].parentNode.parentNode.className = &quot;current&quot;;
arr[i].parentNode.parentNode.parentNode.className = &quot;current&quot;;
&lt;/code&gt;&lt;/pre&gt;
arr[i] is the link itself (&lt;a href rel=&quot;nofollow&quot;&gt;....&lt;/a&gt;)
arr[i].parentNode is the LI tag that contains the link
arr[i].parentNode.parentNode is the submenu (UL tag)
arr[i].parentNode.parentNode.parentNode is the parent element (LI)I hope it&#039;s not too confusing....If you are serious about web development, I recommend you use the Firebug plugin for Firefox. It will show you exactly how properties are applied.</description> <content:encoded><![CDATA[<p>Tim,</p><p>if you have a nested menu structure and want to highlight parent elements as well as children, eg:</p><pre><code>
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Item 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Item 2&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Item 2.1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Item 2.2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Item 2.3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Item 3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</code></pre><p>then, at line 16, you need to add</p><pre><code>
arr[i].parentNode.parentNode.className = "current";
arr[i].parentNode.parentNode.parentNode.className = "current";
</code></pre><p>arr[i] is the link itself (<a
href rel="nofollow">&#8230;.</a>)<br
/> arr[i].parentNode is the LI tag that contains the link<br
/> arr[i].parentNode.parentNode is the submenu (UL tag)<br
/> arr[i].parentNode.parentNode.parentNode is the parent element (LI)</p><p>I hope it&#8217;s not too confusing&#8230;.</p><p>If you are serious about web development, I recommend you use the Firebug plugin for Firefox. It will show you exactly how properties are applied.</p> ]]></content:encoded> </item> <item><title>By: Tim</title><link>http://www.richnetapps.com/automatically_highlight_current_page_in/comment-page-1/#comment-609</link> <dc:creator>Tim</dc:creator> <pubDate>Mon, 21 Dec 2009 19:50:06 +0000</pubDate> <guid
isPermaLink="false">#comment-609</guid> <description>How do you get the parent li to highlight instead of the children li&#039;s in a list...here&#039;s what I have
http://www.capellnet.com/SITETEMPLATE</description> <content:encoded><![CDATA[<p>How do you get the parent li to highlight instead of the children li&#8217;s in a list&#8230;here&#8217;s what I have<br
/> <a
href="http://www.capellnet.com/SITETEMPLATE" rel="nofollow">http://www.capellnet.com/SITETEMPLATE</a></p> ]]></content:encoded> </item> <item><title>By: Tim</title><link>http://www.richnetapps.com/automatically_highlight_current_page_in/comment-page-1/#comment-608</link> <dc:creator>Tim</dc:creator> <pubDate>Mon, 21 Dec 2009 18:41:25 +0000</pubDate> <guid
isPermaLink="false">#comment-608</guid> <description>First of all...THANKS a bunch, this is exactly what I&#039;ve been looking for.
I&#039;m sure I&#039;m missing something on this. But I&#039;m not able to figure out how to get the parent LI to highlight even if it&#039;s a child of that li. So for example if there is any li tags that are underneath the parent to still highlight the parent and not the current li. http://www.capellnet.com/SITETEMPLATEHere&#039;s the code I have currently have for the menu.&lt;a href=&quot;page1.html&quot; rel=&quot;nofollow&quot;&gt;MenuItem 1&lt;/a&gt;
&lt;a href=&quot;page2.html&quot; rel=&quot;nofollow&quot;&gt;MenuItem 1.1&lt;/a&gt;
&lt;a href=&quot;page3.html&quot; rel=&quot;nofollow&quot;&gt;MenuItem 1.2&lt;/a&gt;
&lt;a href=&quot;page4.html&quot; rel=&quot;nofollow&quot;&gt;MenuItem 1.3&lt;/a&gt;
&lt;a href=&quot;page5.html&quot; rel=&quot;nofollow&quot;&gt;MenuItem 2&lt;/a&gt;
&lt;a href=&quot;page6.html&quot; rel=&quot;nofollow&quot;&gt;MenuItem 2.1&lt;/a&gt;
&lt;a href=&quot;page7.html&quot; rel=&quot;nofollow&quot;&gt;MenuItem 2.2&lt;/a&gt;
&lt;a href=&quot;page8.html&quot; rel=&quot;nofollow&quot;&gt;MenuItem 2.3&lt;/a&gt;
&lt;a href=&quot;page9.html&quot; rel=&quot;nofollow&quot;&gt;MenuItem 2.4&lt;/a&gt;
&lt;a href=&quot;page10.html&quot; rel=&quot;nofollow&quot;&gt;MenuItem 2.5&lt;/a&gt;
&lt;a href=&quot;page11.html&quot; rel=&quot;nofollow&quot;&gt;MenuItem 3&lt;/a&gt;
&lt;a href=&quot;page12.html&quot; rel=&quot;nofollow&quot;&gt;MenuItem 4&lt;/a&gt;
&lt;a href=&quot;page13.html&quot; rel=&quot;nofollow&quot;&gt;MenuItem 5&lt;/a&gt;setPage()Here&#039;s the JS info:
arr[i].className = &quot;current&quot;;
arr[i].parentNode.className = &quot;current&quot;;Here&#039;s the CSS for the menu section:
/***TOP NAVMENU***/
#jsddm {
float: left;
width: 922px;
height: 25px;
background-image: url(../images/nav1.gif);
background-repeat: repeat-x;
margin:0;
padding:0;
}
#jsddm li {
float:left;
list-style:none;
}
#jsddm li a {
display: block;
padding: 5px 12px;
text-decoration: none;
background-image: url(../images/nav1.gif);
background-repeat: repeat-x;
font-family: Verdana, Geneva, sans-serif;
font-size: 12px;
font-weight: bold;
color: #666;
width: 91px;
white-space: nowrap;
}
#jsddm li ul {
margin: 0;
padding: 0;
position: absolute;
visibility: hidden;
}
#jsddm li ul li {
float: none;
display: inline;
}
#jsddm li ul li a {
width: auto;
border-bottom: 1px solid #CCC;
}
#jsddm li a:hover { background-image:url(../images/nav2.gif);background-repeat:repeat-x;}
#jsddm li ul li a:hover{background-image:url(../images/nav2.gif);background-repeat:repeat-x;}
#jsddm li a.current {background-image:url(../images/nav3.gif);background-repeat:repeat-x;color:#FFF;}Thanks for any light you can shed on this... :-)</description> <content:encoded><![CDATA[<p>First of all&#8230;THANKS a bunch, this is exactly what I&#8217;ve been looking for.<br
/> I&#8217;m sure I&#8217;m missing something on this. But I&#8217;m not able to figure out how to get the parent LI to highlight even if it&#8217;s a child of that li. So for example if there is any li tags that are underneath the parent to still highlight the parent and not the current li. <a
href="http://www.capellnet.com/SITETEMPLATE" rel="nofollow">http://www.capellnet.com/SITETEMPLATE</a></p><p>Here&#8217;s the code I have currently have for the menu.</p><p> <a
href="page1.html" rel="nofollow">MenuItem 1</a></p><p> <a
href="page2.html" rel="nofollow">MenuItem 1.1</a><br
/> <a
href="page3.html" rel="nofollow">MenuItem 1.2</a><br
/> <a
href="page4.html" rel="nofollow">MenuItem 1.3</a></p><p> <a
href="page5.html" rel="nofollow">MenuItem 2</a></p><p> <a
href="page6.html" rel="nofollow">MenuItem 2.1</a><br
/> <a
href="page7.html" rel="nofollow">MenuItem 2.2</a><br
/> <a
href="page8.html" rel="nofollow">MenuItem 2.3</a><br
/> <a
href="page9.html" rel="nofollow">MenuItem 2.4</a><br
/> <a
href="page10.html" rel="nofollow">MenuItem 2.5</a></p><p> <a
href="page11.html" rel="nofollow">MenuItem 3</a><br
/> <a
href="page12.html" rel="nofollow">MenuItem 4</a><br
/> <a
href="page13.html" rel="nofollow">MenuItem 5</a></p><p>setPage()</p><p>Here&#8217;s the JS info:<br
/> arr[i].className = &#8220;current&#8221;;<br
/> arr[i].parentNode.className = &#8220;current&#8221;;</p><p>Here&#8217;s the CSS for the menu section:<br
/> /***TOP NAVMENU***/<br
/> #jsddm {<br
/> float: left;<br
/> width: 922px;<br
/> height: 25px;<br
/> background-image: url(../images/nav1.gif);<br
/> background-repeat: repeat-x;<br
/> margin:0;<br
/> padding:0;<br
/> }<br
/> #jsddm li {<br
/> float:left;<br
/> list-style:none;<br
/> }<br
/> #jsddm li a {<br
/> display: block;<br
/> padding: 5px 12px;<br
/> text-decoration: none;<br
/> background-image: url(../images/nav1.gif);<br
/> background-repeat: repeat-x;<br
/> font-family: Verdana, Geneva, sans-serif;<br
/> font-size: 12px;<br
/> font-weight: bold;<br
/> color: #666;<br
/> width: 91px;<br
/> white-space: nowrap;<br
/> }<br
/> #jsddm li ul {<br
/> margin: 0;<br
/> padding: 0;<br
/> position: absolute;<br
/> visibility: hidden;<br
/> }<br
/> #jsddm li ul li {<br
/> float: none;<br
/> display: inline;<br
/> }<br
/> #jsddm li ul li a {<br
/> width: auto;<br
/> border-bottom: 1px solid #CCC;<br
/> }<br
/> #jsddm li a:hover { background-image:url(../images/nav2.gif);background-repeat:repeat-x;}<br
/> #jsddm li ul li a:hover{background-image:url(../images/nav2.gif);background-repeat:repeat-x;}<br
/> #jsddm li a.current {background-image:url(../images/nav3.gif);background-repeat:repeat-x;color:#FFF;}</p><p>Thanks for any light you can shed on this&#8230; <img
src='http://www.richnetapps.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: Armand Niculescu</title><link>http://www.richnetapps.com/automatically_highlight_current_page_in/comment-page-1/#comment-606</link> <dc:creator>Armand Niculescu</dc:creator> <pubDate>Fri, 18 Dec 2009 09:13:00 +0000</pubDate> <guid
isPermaLink="false">#comment-606</guid> <description>It&#039;s actually a lot easier to do this in PHP but it depends on how your site is set up -- there is no general answer.
Generally speaking, you output the menu and for each item you check if it&#039;s the current page (how? depends)
E.g.:
&lt;li &gt;Item 1
&lt;li &gt;Item 2
...</description> <content:encoded><![CDATA[<p>It&#8217;s actually a lot easier to do this in PHP but it depends on how your site is set up &#8212; there is no general answer.<br
/> Generally speaking, you output the menu and for each item you check if it&#8217;s the current page (how? depends)<br
/> E.g.:<br
/> &lt;li &gt;Item 1<br
/> &lt;li &gt;Item 2<br
/> &#8230;</p> ]]></content:encoded> </item> <item><title>By: ghprod</title><link>http://www.richnetapps.com/automatically_highlight_current_page_in/comment-page-1/#comment-604</link> <dc:creator>ghprod</dc:creator> <pubDate>Wed, 16 Dec 2009 17:58:48 +0000</pubDate> <guid
isPermaLink="false">#comment-604</guid> <description>Hi, how to get current page but in PHP without JS?regardsthanks</description> <content:encoded><![CDATA[<p>Hi, how to get current page but in PHP without JS?</p><p>regards</p><p>thanks</p> ]]></content:encoded> </item> <item><title>By: Bill Dashfield</title><link>http://www.richnetapps.com/automatically_highlight_current_page_in/comment-page-1/#comment-57</link> <dc:creator>Bill Dashfield</dc:creator> <pubDate>Tue, 10 Mar 2009 01:44:34 +0000</pubDate> <guid
isPermaLink="false">#comment-57</guid> <description>Nice little script - just what I was looking for.&lt;br /&gt;
&lt;br /&gt;
One little mistake, I think (also what Alice was trying to say?):&lt;br /&gt;
&lt;br /&gt;
In your explanation you say &#039;all links that are contained in the navigation bar (any tag with id=&quot;navbar&quot;)&#039;&lt;br /&gt;
but your code says:&lt;br /&gt;
&lt;br /&gt;
if (document.getElementById(&quot;nav&quot;)!=null)	                setActiveMenu(document.getElementById(&quot;nav&quot;).getElementsByTagName(&quot;a&quot;)&lt;br /&gt;
&lt;br /&gt;
To find your navigation links, I think the &quot;nav&quot; in the code should be &quot;navbar&quot;:&lt;br /&gt;
if (document.getElementById(&quot;navbar&quot;)!=null)	                setActiveMenu(document.getElementById(&quot;navbar&quot;).getElementsByTagName(&quot;a&quot;)&lt;br /&gt;
&lt;br /&gt;
Thanks Bill</description> <content:encoded><![CDATA[<p>Nice little script &#8211; just what I was looking for.</p><p>One little mistake, I think (also what Alice was trying to say?):</p><p>In your explanation you say &#8216;all links that are contained in the navigation bar (any tag with id=&#8221;navbar&#8221;)&#8217;<br
/> but your code says:</p><p>if (document.getElementById(&#8220;nav&#8221;)!=null)	                setActiveMenu(document.getElementById(&#8220;nav&#8221;).getElementsByTagName(&#8220;a&#8221;)</p><p>To find your navigation links, I think the &#8220;nav&#8221; in the code should be &#8220;navbar&#8221;:<br
/> if (document.getElementById(&#8220;navbar&#8221;)!=null)	                setActiveMenu(document.getElementById(&#8220;navbar&#8221;).getElementsByTagName(&#8220;a&#8221;)</p><p>Thanks Bill</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Served from: box346.bluehost.com @ 2010-03-11 05:11:31 by W3 Total Cache -->