Exforsys

Free Training

How to set current menu style

This is a discussion on How to set current menu style within the Html forums, part of the Programming Talk category; Hi, iam try to set style to current menu,how to set style to current menu? iam write focus attribute in ...

Go Back   Exforsys > Programming Talk > Html

Exforsys.com

  #1 (permalink)  
Old 05-22-2009, 04:23 AM
Junior Member
 
Join Date: Nov 2006
Posts: 26
megabyte is on a distinguished road
How to set current menu style

Hi,

iam try to set style to current menu,how to set style to current menu? iam write focus attribute in css.but its not working.any one help me.


HTml Code:

HTML Code:
<div class="urbangreymenu">
<ul>
<li><a href="#">Design</a></li>
<li><a href="#">Analysis</a></li>
<li><a href="#">FMEA</a></li>
<li><a href="#">CAD</a></li>
<li><a href="#">NPI</a></li>
<li><a href="#">Contract</a></li>
</ul>
</div>



CSS Code :


HTML Code:
<style type="text/css">

.urbangreymenu{
width: 210px; /*width of menu*/
margin-top:25px;
}

.urbangreymenu .headerbar{
font: bold 13px Verdana;
color: white;
background: #606060 url(media/arrowstop.gif) no-repeat 8px 6px; /*last 2 values are the x and y coordinates of bullet image*/
margin-bottom: 0; /*bottom spacing between header and rest of content*/
text-transform: uppercase;
padding: 7px 0 7px 31px; /*31px is left indentation of header text*/
}

.urbangreymenu ul{
list-style-type: none;
margin: 0;
padding: 0;
margin-bottom: 0; /*bottom spacing between each UL and rest of content*/
}

.urbangreymenu ul li{
padding-bottom: 2px; /*bottom spacing between menu items*/
}

.urbangreymenu ul li a{
font: normal 12px Arial;
color: black;
display: block;
padding: 7px 0;
line-height: 17px;
padding-right: 15px; /*link text is indented 8px*/
text-decoration: none;
text-align:right;
}

.urbangreymenu ul li a:focus {
padding-right: 15px;
color: red;
background-image:url(images/lefthover.jpg);
background-repeat:no-repeat;
}

#current{
padding-right: 15px;
color: black;
background-image:url(images/lefthover.jpg);
background-repeat:no-repeat;
}

.urbangreymenu ul li a:hover{ /*hover state CSS*/
padding-right: 15px;
color: red;
font-weight:bold;
background-image:url(images/lefthover.jpg);
background-repeat:no-repeat;
}
</style>

Thanks,
Megabyte

Last edited by megabyte; 05-22-2009 at 04:26 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-28-2009, 11:05 AM
Junior Member
 
Join Date: Mar 2009
Posts: 12
chowexfo is on a distinguished road
Use this Javascript Function

add this java script in header section.willl you change your CSS id in java script whatever you want

HTML Code:
function extractPageName(hrefString)
{
	var arr = hrefString.split('/');
	return  (arr.length<2) ? hrefString : arr[arr.length-2].toLowerCase() + arr[arr.length-1].toLowerCase();               
}

function setActiveMenu(arr, crtPage)
{
	for (var i=0; i

Your HTML code set like this

HTML Code:
<div id="urbangreymenu">
<ul>
<li><a href="#">Text</a></li>
<li><a href="#">Text</a></li>
<li><a href="#">Text</a></li>
<li><a href="#">Text</a></li>
<li><a href="#">NPI</a></li>
<li><a href="#">Text</a></li>
</ul>
<script language="javascript">setPage()</script>
</div>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-29-2009, 10:47 PM
Junior Member
 
Join Date: Mar 2009
Posts: 12
chowexfo is on a distinguished road
code is missing in above post
PHP Code:
function extractPageName(hrefString)
{
    var 
arr hrefString.split('/');
    return  (
arr.length<2) ? hrefString arr[arr.length-2].toLowerCase() + arr[arr.length-1].toLowerCase();               
}

function 
setActiveMenu(arrcrtPage)
{
for (var 
i=0i<arr.lengthi++)
    {
        if(
extractPageName(arr[i].href) == crtPage)
        {
            if (
arr[i].parentNode.tagName != "DIV")
            {
                
arr[i].className "current";
                
arr[i].parentNode.className "current";
            }
        }
    }
}

function 
setPage()
{
    
hrefString document.location.href document.location.href document.location;

    if (
document.getElementById("urbangreymenu")!=null)
        
setActiveMenu(document.getElementById("urbangreymenu").getElementsByTagName("a"), extractPageName(hrefString));

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit Tech FAQ 0 06-01-2004 07:00 AM
Comp.Sys.Acorn.FAQ part 1 of 4 Paul Vigay Tech FAQ 0 05-31-2004 09:00 PM
Comp.Sys.Acorn.FAQ part 1 of 4 Paul Vigay Tech FAQ 0 04-30-2004 09:00 PM
Solaris x86 FAQ 2/2 Dan Anderson Tech FAQ 0 04-27-2004 08:24 PM
[FAQ] FileMaker Pro - database for Macintosh and Windows Martin Trautmann Tech FAQ 0 04-17-2004 08:26 AM


All times are GMT -4. The time now is 10:18 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
Copyright 2004 - 2009 Exforsys Inc. All rights reserved.