Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

a href"#" is not working with :focus on firefox browser

Tags:

html

css

I have this menu that I customized to use it like a select. It work just fine on ie, chrome but on firefox is not working. Normal behavior is: when menu is expanded on focus the links are displayed (help and logoff) and if you click on them will be redirected in other page in the same browser. Wrong behavior on firefox: menu si expanded on focus but links (hep and logoff) are not redirecting.

    <ul id="main">
                <li class="username" tabindex="1" >  <a>USER</a>
                    <ul class="curent_buser">
                        <li class="ai"><a class="jaximus"href="http://en.wikipedia.org/wiki/Wiki">Help</a></li>
<li class="aj"><a class="jaximus" href="http://en.wikipedia.org/wiki/Wiki" name="logoff">Log Off</a></li>                </ul>
                </li>
            </ul>

Why is doing this firefox??? I have last version of ff :|

here is a fiddle example: http://jsfiddle.net/RwtHn/1152/

like image 754
BurebistaRuler Avatar asked Aug 28 '12 09:08

BurebistaRuler


People also ask

WHAT IS A href in HTML?

The href attribute specifies the URL of the page the link goes to. If the href attribute is not present, the <a> tag will not be a hyperlink.

What is href in URL?

The href attribute link (short for “Hypertext REFerence”) indicates the relationship between pages to search engines. href is an attribute of the anchor tag and contains two components: The URL (the actual link) and. The clickable text or object that users will see on the page (known as the “anchor text”)

WHY WE USE A href in HTML?

The HTML <a> href Attribute is used to specify the URL of the page that the link goes to. When the href attribute is not present in the <a> an element that it will not be a hyperlink. This attribute is used to specify a link to any address.


2 Answers

It's because the instant you press down on either "Help" or "Log Off" the encompasing a element gets the focus and is active, which "deactivates" this rule:

#main li:focus ul, #main a:active + ul{
display:block;
}

Thus the link (or more specifically the ul encompassing the link) vanishes before the click on the link has been completed.

At least this seems to be how firefox handles it.

EDIT: It should work with adding the selector

#main li.username:active ul

to above rule.

like image 149
gabtub Avatar answered Sep 24 '22 23:09

gabtub


Change your final rule to this:

#main li:focus ul, #main a:active + ul,
#main li ul:hover
{
display:block;
}

The #main li ul:hover rule means that the submenu will stay open long enough for the click to register.

See forked JS Fiddle

p.s. Cool trick, I've never seen a select box launched like this before.

like image 25
Jason O'Neil Avatar answered Sep 23 '22 23:09

Jason O'Neil