Jake Churchill

… on Flex, ColdFusion, FarCry, and much more …

  • Home
  • About
  • Projects

20

Mar

IE menu hover fix

Posted by Jake Churchill  Published in Browsers, CSS, Javascript

I run into an issue a lot with fly-out and dropdown menus not always layering on TOP of the subsequent content. I see this most often with Farcry because that is what I use for a lot of sites but I see it elsewhere as well. It can be the most irritating thing in the world to deal with but it CAN be fixed.

In farcry sites, there is a navigation.js or hover.js file that is loaded which provides a nice *hack* for IE6. The purpose of this is that for multi-level navigations, the dropdown/flyout appears when you hover over an LI tag. IE6 only recognizes the seudo element (:hover) on A tags so this javascript file manually adds a class to every LI tag that is a child of a particular element. I.E. if your outer UL has an ID of “menu” this class will be added to all sub-elements.

Here’s what the basic javascript looks like:

hover = function() {
var nav = document.getElementById("menu");
if(nav){
var nodes = nav.getElementsByTagName("li")
for (var i=0; i<nodes.length; i++) {
nodes[i].onmouseover=function() {
this.className+=" hover";
}
nodes[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" hover\\b"), "");
}
}
}
}
if (window.attachEvent) window.attachEvent("onload", hover);

I know, not necessarily that “basic” but all it’s doing is attaching an “onMouseOver” and “onMouseOut” event handler to all LI tags under the element with ID “menu”.

Now, back to the original problem… The dropdown/flyout menus don’t always layer OVER the content in the page. This is thanks to IE rendering all elements with a z-index of 0. Regardless of what you set this to in your CSS (generally z-index of the flyout is higher than the z-index of the page) IE will make it all 0 at the time of loading.

I dealt with this problem for months always hacking my way through a fix depending on the site until it finally dawned on me. I can use this javascript to my advantage because this code runs “onload” (once the page has loaded). Conveniently, this is also after z-indexes have been butchered by IE. So, here is a quick alteration to that javascript that has fixed every problem I’ve run into thusfar:

hover = function() {
var nav = document.getElementById("menu");
nav.style.zIndex = 100;
if(nav){
var nodes = nav.getElementsByTagName("li")
for (var i=0; i<nodes.length; i++) {
nodes[i].onmouseover=function() {
this.className+=" hover";
}
nodes[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" hover\\b"), "");
}
}
}
}
if (window.attachEvent) window.attachEvent("onload", hover);

Notice the line “nav.style.zIndex = 100;”. That’s all it took. Of course, your situation may be much more complex than this and may require more layering of elements. Using this same example you can simply reset z-indexes even if you don’t have a complex menu. Here would be an example of that:

resetZIndexes= function() {
var nav = document.getElementById("menu").style.zIndex = 100;
// other elements would go here
}
if (window.attachEvent) window.attachEvent("onload", resetZIndexes);

I really hope this helps someone avoid the agonizing pain that I had to endure prior to figuring this out.

4 comments

25

Jun

CSS Presentation

Posted by Jake Churchill  Published in CSS

I gave a presentation about Cascading Style Sheets and why they are important last night at the local Nebraska ColdFusion Users Group last night. Thanks to those who attended and brought questions.

For anyone interested, the presentation materials, including examples are available online at http://jake.cfwebtools.com/css_pres/css.zip.

As always, questions are welcome via my blog, via email or in person :)

no comment

13

Feb

CSS Rounded Corners

Posted by Jake Churchill  Published in CSS

One thing that I’ve learned a lot about in the last year and a half is CSS. Along with any other language, there is not one right way to do things in CSS. But, there’s usually one way that will make your life in the future much easier. The trick is finding it…


continue reading "CSS Rounded Corners"

no comment

17

Sep

IE6 PNG Transparency Fix

Posted by Jake Churchill  Published in CSS

I had to use a .png file with alpha transparency on a site which works fine in both IE7 and Firefox 2. However, IE6 does not like it at all. There is a fix out there called pngfix.js which works great if you have an img tag but this was a background image set in the CSS. Here’s what I did:

#wrap {
	margin:0px auto;
	background-image:url('/IMG/wrap_bg.png');
	background-repeat:repeat-y;
}
* html #wrap {
	background-image:none;
	filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/IMG/wrap_bg.png', sizingMethod='scale');
}

This worked like a charm!

3 comments

6

Aug

Farcry dmCSS How-To

Posted by Jake Churchill  Published in CSS, Farcry

I’ve been developing using Farcry for nearly a year now and the dmCSS type has always puzzled me. I knew it had to be a way to have node-specific CSS but how do you use it? I finally took the time to learn how and here’s what I found.


continue reading "Farcry dmCSS How-To"

no comment

31

Jul

CSS close window link

Posted by Jake Churchill  Published in CSS, Javascript

Honestly, I am blogging this to satisfy a coworker (Axel) who thought this was really cool.

You see this kind of thing all the time, a little X on a window that gets open that allows you to close it. Not the X close button on the title bar of the window but a little close link with an x. I’m a bit of a CSS geek so I made this in CSS. Here’s the code:

<a href="Javascript:window.close()" style="text-decoration:none;">close <span style="border:1px solid gray;width:15px;text-align:center;font-size:8pt;cursor:hand;">X</span></a>

Test It!

no comment

1

May

CSS Browser Hacks

Posted by Jake Churchill  Published in Browsers, CSS

I searched for a long time on how to hack different browsers in CSS so I thought I’d post techniques for the 3 most popular browsers (IE6, IE7 & Firefox).

The Technique:

I strongly recommend writing CSS and testing it in Firefox. Get it to look right, then hack out IE6 & IE7. Nothing against any of the browsers but this has been the most effective technique for me. You will usually need to make several adjustments to widths and heights, padding and margints, etc in IE6 and IE7 should follow pretty much what Firefox does. There are a few exceptions like floating and positioning that I’ve found.


continue reading "CSS Browser Hacks"

2 comments

13

Nov

Quick Browser Detection for CSS Script

Posted by Jake Churchill  Published in Browsers, CSS, ColdFusion

Here’s a quick script that I use in a lot of header files to detect the user’s browser. else represents Firefox in most cases.

<cfif Trim(ListGetAt(CGI.HTTP_USER_AGENT, 2, ";")) EQ "MSIE 6.0">
        <link rel="stylesheet" type="text/css" href="css/main_IE6.css" media="screen" />
    <cfelseif Trim(ListGetAT(CGI.HTTP_USER_AGENT, 2, ";")) EQ "MSIE 7.0">
        <link rel="stylesheet" type="text/css" href="css/main_IE7.css" media="screen" />
    <cfelse>
        <link rel="stylesheet" type="text/css" href="css/main_FF.css" media="screen" />
    </cfif>
no comment

7

Nov

A CSS Menu in Farcry That Stays Open???

Posted by Jake Churchill  Published in CSS, Farcry

I truly thought this project would be the end of me. The project was to create a CSS menu that pops up instead of down. Simple enough. However, when the user clicked on a child item, that menu tree had to stay open. If you’re at all familiar with CSS menus you know that they basically revolve around an unordered list with several classes and they turn the display property in CSS on and off. Of course, this wouldn’t work because the use of :hover was out. So, here’s how I accomplished this (2 level menus only)…

1) Create a custom nav class based on the generic. mine neiNav.

2) Keep track of where you are in the navigation tree. In my case I was using 2 levels only. The first level was a child of Home and the 2nd level was a child of any particular item in the first level. Since the point is to keep the child menu open if the user selects something from it, we only need to keep track of the object ID in the 2nd level. I did this with the following:

<cfparam name="parentNavID" default="">
<cfif application.factory.otree.getparentID(request.navid).parentid NEQ application.navid.home>
	<cfset parentNavID = application.factory.oTree.getParentID(request.navid).parentId>
</cfset></cfif>
</cfparam>

This way we know that if the parentNavID has a value, then the value it contains represents a level 1 menu item. Thus, the tree directly following this item needs to stay open

continue reading "A CSS Menu in Farcry That Stays Open???"

no comment

Search

Blog Feed

  • Add blog to any reader
  • Comments Rss
May 2013
M T W T F S S
« Feb    
 12345
6789101112
13141516171819
20212223242526
2728293031  

 

May 2013
M T W T F S S
« Feb    
 12345
6789101112
13141516171819
20212223242526
2728293031  

Subscribe to Blog

Your email:

Subscribe   Unsubscribe

Archives

Categories

  • Browsers (3)
  • CFEclipse (2)
  • ColdFusion (7)
  • CSS (9)
  • Farcry (33)
    • Farcry Examples (2)
    • Farcry Users (1)
  • Flash (1)
  • Flex (14)
  • Javascript (5)
  • Life & Fun (3)
  • Microsoft Office (1)
  • Misc (4)
  • Random Posts (1)
  • SQL (2)
  • Uncategorized (2)

Blogroll

  • Axel Jensen
  • Ben Forta
  • Coldfusion Muse
  • Fullasagoog
  • Nicole Rutter
  • Ray Camden
  • Sandy Clark
  • Stillnet Studios

Recent Posts

  • FCKEditor Firefox 3.6 Bug (Year 2010 Bug)
  • ColdFusion using Java for regex replace
  • ColdFusion VirtualMerchant CFC
  • Farcry Navigation Move Permissions
  • Delete Mail via POP Script

Recent Comments

  • James Moberg on FCKEditor Firefox 3.6 Bug (Year 2010 Bug)
  • Jake Churchill on ColdFusion using Java for regex replace
  • Ben Nadel on ColdFusion using Java for regex replace
  • Peter Boughton on ColdFusion using Java for regex replace
  • Peter Boughton on ColdFusion using Java for regex replace

Recent Post

  • FCKEditor Firefox 3.6 Bug (Year 2010 Bug)
  • ColdFusion using Java for regex replace
  • ColdFusion VirtualMerchant CFC
  • Farcry Navigation Move Permissions
  • Delete Mail via POP Script
  • Flex 2 Datagrid not highlighting row (UPDATE)
  • Flex 2 Datagrid not highlighting row
  • Flex Dynamic casting of data
  • Reboot XP PC over Remote Desktop
  • Dynamically instantiate a class

Recent Comments

  • James Moberg in FCKEditor Firefox 3.6 Bug (Year 2010 Bug)
  • Jake Churchill in ColdFusion using Java for regex replace
  • Ben Nadel in ColdFusion using Java for regex replace
  • Peter Boughton in ColdFusion using Java for regex replace
  • Peter Boughton in ColdFusion using Java for regex replace
  • Matthew in ColdFusion using Java for regex replace
  • Matthew in ColdFusion using Java for regex replace
  • Jake Churchill in Flex Channel.Connect.Failed error NetConnection.Ca…
  • Flex Guy in Flex Channel.Connect.Failed error NetConnection.Ca…
  • Dexter in Flex Custom Preloader without SWF
© 2008 Jake Churchill is proudly powered by WordPress
Theme designed by Roam2Rome