A while back I blogged about a div layer positioning glitch that occurs in IE when you position a cfinput datefield above a cflayout or cfdiv generated div layer. This problem seems to be cause by the fact that in IE, a relative positioned element influences the stacking order of it's child-elements, which violates the CSS specification, but who really needs standards anyways right?

Well, I figured out a way to workaround it, and it's really stupid that I didn't think of it before. I kept trying (unsuccessfully) to write a JavaScript function that would find the layers and reposition them after the page loaded, when finally a light bulb went on in my head, and I came up with a much simpler solution.

I simply used div layers so that the date field (which gets displayed at the top of the page) gets loaded by the browser after the cflayout stuff (which appears at the bottom of the page). Now as far as IE is concerned the calendar div layer now is at the top of the stack because it came last in the HTML source. Then I use CSS to position the sections of content where I want them to appear on the page.

First here is the code that generates the bug (click here in IE to see the bug I am talking about):

<cfparam name="StartDate" default="#dateformat(now(),'mm/dd/yyyy')#">
<cfform>
<cfinput name="StartDate" value="#StartDate#" type="DateField" onkeypress="loadDate(event);">
</cfform>
<br><br>
<cflayout type="tab" name="MyLayout">
<cflayoutarea name="Tab1" title="My First Tab" style="height:100%">
<br><br>
   <table width="95%" align="center"><tr><td>
   <cfdiv id="MyFirstDivLayer">
   Here is a bunch of content that is in my div layer Here is a bunch of content that is in my div layerHere is a bunch of content that is in my div layer<br>Here is a bunch of content that is in my div layerHere is a bunch of content that is in my div layerHere is a bunch of content that is in my div layerHere is a bunch of content that is in my div layer
   </cfdiv>
   </td></tr></table>
</cflayoutarea>
<cflayoutarea name="Tab2" title="My Second Tab" style="height:100%">
<br><br>
   <table width="95%" align="center"><tr><td>
   <cfdiv id="MySecondDivLayer">
   Here is a bunch of content that is in my div layer Here is a bunch of content that is in my div layerHere is a bunch of content that is in my div layer<br>Here is a bunch of content that is in my div layerHere is a bunch of content that is in my div layerHere is a bunch of content that is in my div layerHere is a bunch of content that is in my div layer
   </cfdiv>
   </td></tr></table>
</cflayoutarea>
<cflayoutarea name="Tab3" title="My Third Tab" style="height:100%">
<br><br>
   <table width="95%" align="center"><tr><td>
   <cfdiv id="MyThirdDivLayer">
   Here is a bunch of content that is in my div layer Here is a bunch of content that is in my div layerHere is a bunch of content that is in my div layer<br>Here is a bunch of content that is in my div layerHere is a bunch of content that is in my div layerHere is a bunch of content that is in my div layerHere is a bunch of content that is in my div layer
   </cfdiv>
   </td></tr></table>
</cflayoutarea>
</cflayout>

Now here is the code with the workaround to solve the layer positioning issue (Click here in IE to see it with my workaround in place):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
   <title>DateField and CFDiv Bug Workaround</title>
   <style>
      .topDiv{position:absolute;
            top: 10px;}
      .bottomDiv{position:absolute;
            top: 30px;}
   </style>
</head>

<body>
<div class="bottomDiv">
<cflayout type="tab" name="MyLayout">
<cflayoutarea name="Tab1" title="My First Tab" style="height:100%">
<br><br>
   <table width="95%" align="center"><tr><td>
   <cfdiv id="MyFirstDivLayer" style="z-index: -1000;">
   Here is a bunch of content that is in my div layer Here is a bunch of content that is in my div layerHere is a bunch of content that is in my div layer<br>Here is a bunch of content that is in my div layerHere is a bunch of content that is in my div layerHere is a bunch of content that is in my div layerHere is a bunch of content that is in my div layer
   </cfdiv>
   </td></tr></table>
</cflayoutarea>
<cflayoutarea name="Tab2" title="My Second Tab" style="height:100%">
<br><br>
   <table width="95%" align="center"><tr><td>
   <cfdiv id="MySecondDivLayer" style="z-index: -1000;">
   Here is a bunch of content that is in my div layer Here is a bunch of content that is in my div layerHere is a bunch of content that is in my div layer<br>Here is a bunch of content that is in my div layerHere is a bunch of content that is in my div layerHere is a bunch of content that is in my div layerHere is a bunch of content that is in my div layer
   </cfdiv>
   </td></tr></table>
</cflayoutarea>
<cflayoutarea name="Tab3" title="My Third Tab" style="height:100%">
<br><br>
   <table width="95%" align="center"><tr><td>
   <cfdiv id="MyThirdDivLayer" style="z-index: -1000;">
   Here is a bunch of content that is in my div layer Here is a bunch of content that is in my div layerHere is a bunch of content that is in my div layer<br>Here is a bunch of content that is in my div layerHere is a bunch of content that is in my div layerHere is a bunch of content that is in my div layerHere is a bunch of content that is in my div layer
   </cfdiv>
   </td></tr></table>
</cflayoutarea>
</cflayout>
</div>
<div class="topDiv">
<cfparam name="StartDate" default="#dateformat(now(),'mm/dd/yyyy')#">
<cfform>
<cfinput name="StartDate" value="#StartDate#" type="DateField" onkeypress="loadDate(event);">
</cfform>
</div>
</body>
</html>

I'm not sure if that solution will work for everyone, but it worked in my application and my IE users are happy now.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Aaron Longnion's Gravatar Nice Scott! heh, I needed this exact workaround about 2 months ago ;) ...so, we had to redesign the form to make sure the calendar div thing couldn't possibly overlay another part of the form improperly. I'll stick this in my bag o tricks for next time. Thanks!

btw - can you update your blog software to allow plus signs in email addresses (which is valid) - I'd like to enter something like myemailhandle+blogentry@gmail.com
# Posted By Aaron Longnion | 6/26/08 12:24 PM
Henry's Gravatar I wonder if this 'bug' will ever be fixed in CF8.02...
# Posted By Henry | 7/7/08 5:04 PM
Scott Bennett's Gravatar @Henry,

The problem is that this bug is really with IE more than with CF. The CF code is generating the calendar div layer with a z-index of over 9000 which, according to the World Wide Web Consortium CSS guidelines, should cause it to appear above any of the other div layers on the page (provided there are less then 9000 other layers on the page). Most likely Adobe engineers will have to take a similar approach as the one I used and have the calendar div layer always get generated at the bottom of the HTML source code and generate CSS to position it so that it appears to the right of it's related input field. I am not sure how easy that would be for Adobe to implement, or how big a priority it is, but I do know they are aware of the issue and that it is on the list of things that will get fixed someday.
# Posted By Scott Bennett | 7/8/08 1:50 PM
Shifty's Gravatar This is exactly what I was looking for. I would've never thought of absolute div positioning. Keep fighting the good fight of working around IE's faults! If only all browsers could be as easy to code for as Firefox.
# Posted By Shifty | 8/19/08 2:19 PM
modsyn's Gravatar Another simpler solution that doesn't deal with absolute positioning is to wrap the datefield in a div and give it the following style attributes:

<div style="clear:both;position:relative;z-index:2;">
<cfinput type="datefield" name="cal"/>
</div>
# Posted By modsyn | 11/14/08 3:20 PM
Sven Hiltner's Gravatar brilliant modsyn, it simly works with fewest effort
# Posted By Sven Hiltner | 2/18/09 9:51 AM
David's Gravatar Hi Scott,

I am having a problem with the CF datepicker in FF V 3.5.1.

http://www.neale.ca/test.cfm

The datepicker will popup in IE but nothing happens when you click the date icon in FF?

Any ideas?
# Posted By David | 7/31/09 8:30 PM
David's Gravatar Scott this has been fixed. The cfform tag must reside outside table tags for FF to work.
# Posted By David | 7/31/09 9:44 PM
https://www.bababorses.de/Louis-Vuitton-Damier-Ebene-Canvas-Clapton-PM-Bag-N44243-Magnolia-2361-it.html https://www.bababorses.de/Louis-Vuitton-LV-Trainer-Men-s-Sneakers-Top-Quality-15-5322-it.html https://www.bababorses.de/Celine-Small-Cabas-Bag-In-Black-Leather-it-2087 https://www.bababorses.de/Louis-Vuitton-Heel-10cm-Call-Back-Sandals-Nude-6162-it.html https://www.bababorses.de/LOUIS-VUITTON-BREA-MM-Monogram-Vernis-Leather-In-Magenta-4069-it.html https://www.bababorses.de/Louis-Vuitton-Ring-09-557-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-LV-Square-Espadrilles-Slipper-Sandals-Brown-6371-it.html https://www.bababorses.de/Prada-Golden-Saffiano-Calfskin-Leather-Top-Handle-Bag-it-2956 https://www.bababorses.de/Dior-Diorissimo-Small-Bag-Black-Nappa-Leather-Silvery-Hardware-8001-it-22 https://www.bababorses.de/Louis-Vuitton-Idylle-Blossom-Charms-Necklace-Q94360-406-it.html https://www.bababorses.de/Louis-Vuitton-Color-Blossom-BB-Star-Pendant-Necklace-Red-Gold-309-it.html https://www.bababorses.de/Bvlgari-Serpenti-Original-Leather-Framed-Pochette-Sky-Blue-82121-it-1938 https://www.bababorses.de/Louis-Vuitton-Horizon-55-Trolley-Travel-Luggage-Bag-Taiga-Leather-M30331-Red-6892-it.html https://www.bababorses.de/Fendi-By-The-Way-Small-Croc-Satchel-White-it-2731 https://www.bababorses.de/Louis-Vuitton-Monogram-Canvas-and-PVC-Nano-Bag-M61114-3176-it.html https://www.bababorses.de/Louis-Vuitton-Sarah-Multicartes-Wallet-M61273-Hot-Pink-7624-it.html https://www.bababorses.de/louis-vuitton-speedy-30--Damier-Azur-Canvas-n44367-2300-it.html https://www.bababorses.de/Hermes-Birkin-35cm-cattle-skin-vein-Handbags-blue-golden-it-907 https://www.bababorses.de/Saint-Laurent-Baby-Sac-De-Jour-Bag-In-Rose-Grained-Leather-it-3322 https://www.bababorses.de/Louis-Vuitton-Twist-MM-M53531-M53532-2775-it.html https://www.bababorses.de/Louis-Vuitton-Sunglasses-133-978-it.html https://www.bababorses.de/Louis-Vuitton-Neverfull-MM-M54185-Black-2705-it.html https://www.bababorses.de/Prada-Saffiano-East-West-Medium-Tote-Bag-Nero-it-3042 https://www.bababorses.de/Louis-Vuitton-Compact-Wallet-in-Monogram-Canvas-M63041-7399-it.html https://www.bababorses.de/Prada-Mens-Leather-Pouch-3312-Black-it-3099 https://www.bababorses.de/Louis-Vuitton-Women-s-Escale-Lock-It-Flat-Mule-1A7TOX-Pink-5965-it.html https://www.bababorses.de/Fendi-Baguette-Micro-Monster-Bag-Purple-Multi-it-533 https://www.bababorses.de/Louis-Vuitton-LV-Angel-Stud-Earrings-M64293-435-it.html https://www.bababorses.de/Louis-Vuitton-Damier-Ebene-Canvas-Zippy-Wallet-Evasion-M61360-7219-it.html https://www.bababorses.de/LOUIS-VUITTON-CATOGRAM-SQUARE-SCARF-MP2266-4818-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Empreinte-Triangle-Shaped-Messenger-Bag-M54330-Black-3865-it.html https://www.bababorses.de/Balenciaga-Velo-Anthracite-store-it-1723 https://www.bababorses.de/Chloe-Marcie-Medium-Satchel-Bag-Cobalt-it-2283 https://www.bababorses.de/louis-vuitton-epi-leather-Soufflot-BB-bag-m55613-black-2580-it.html https://www.bababorses.de/Louis-Vuitton-Dauphine-MM-M55735-4512-it.html https://www.bababorses.de/Louis-Vuitton-Crafty-NeoNoe-MM-bag-black-M45497-2980-it.html https://www.bababorses.de/Louis-Vuitton-Men-Box-Bag-Shoulder-Body-Bag-M44157-Brown-3136-it.html https://www.bababorses.de/Prada-Saffiano-Double-Zip-Executive-Tote-Bag-Gray-it-3025 https://www.bababorses.de/Louis-Vuitton-Epi-Leather-NeoNoe-BB-Bucket-Bag-M53610-Indigo-2564-it.html https://www.bababorses.de/Saint-Laurent-Small-Monogram-Tassel-Satchel-In-Red-Crocodile-Leather-it-3158 https://www.bababorses.de/Louis-Vuitton-Iphone-Case-LV18-59-it.html https://www.bababorses.de/LOUIS-VUITTON--CLASSIC-MINI-PACKBACK-2872-it.html https://www.bababorses.de/Balenciaga-Velo-Anthracite-store-it-1723 https://www.bababorses.de/Louis-Vuitton-Monogram-Ebene-Canvas-Pegase-Legere-53-Business-Rolling-Luggage-6950-it.html https://www.bababorses.de/Louis-Vuitton-Crocodilien-Brillant-Capucines-Mini-Bag-N93429-Black-2231-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Hoodie-Jacket-Black-1526-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Coated-Canvas-Popincourt-PM-M43462--Raisin-3345-it.html https://www.bababorses.de/Louis-Vuitton-Lockme-Cabas-Tote-M55028-Black-4530-it.html https://www.bababorses.de/Givenchy-Antigona-Small-Leather-Satchel-Bag-Black-it-2432 https://www.bababorses.de/Louis-Vuitton-Monogram-Canvas-Small-Malle-Chain-Bag-3294-it.html https://www.bababorses.de/Louis-Vuitton-Epi-Leather-Zippy-Wallet-M62304-Red-7304-it.html https://www.bababorses.de/Louis-Vuitton-Iphone-Case-LV113-38-it.html https://www.bababorses.de/Louis-Vuitton-Heel-10.5cm-Eyeline-Pumps-Python-Pattern-Suede-Black-5999-it.html https://www.bababorses.de/LOUIS-VUITTON-PEGASE-LEGERE-REGATTA-N41620-MONOGRAM-CANVAS-6974-it.html https://www.bababorses.de/Louis-Vuitton-Kimono-Wallet-M56175-Pink-7437-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Tapestry-Denim-Bidart-Espadrilles-Blue-5726-it.html https://www.bababorses.de/Louis-Vuitton-Women-s-Escale-Shirtdress-Blue-1709-it.html https://www.bababorses.de/Louis-Vuitton-Montaigne-MM-M41048-Black-4597-it.html https://www.bababorses.de/Louis-Vuitton-Heel-10cm-Crystals-Call-Back-Sandals-Suede-Red-6160-it.html https://www.bababorses.de/Hermes-Bolide-31cm-Togo-Leather-Green-Bag-it-1070 https://www.bababorses.de/Replica-Hermes-Wallet-H001-Wallet-Cow-Leather-Green-it-1558 https://www.bababorses.de/Celine-Medium-Luggage-Tote-Black-Brown-White-Bag-it-2168 https://www.bababorses.de/Louis-Vuitton-Pochette-Voyage-MM-Bag-Damier-Graphite-Canvas-Pixel-N60176-Green-7278-it.html https://www.bababorses.de/Fendi-Black-Snake-Veins-Leather-With-Beige-Ferrari-Leather-Top-handle-Bag-it-469 https://www.bababorses.de/Louis-Vuitton-All-over-Monogram-Sleeveless-Belted-Dress-Navy-1375-it.html https://www.bababorses.de/Louis-Vuitton-Ring-02-560-it.html https://www.bababorses.de/Louis-Vuitton-Iphone-Case-LV32-76-it.html https://www.bababorses.de/Louis-Vuitton-Dauphine-MM-M55071-Blue-4511-it.html https://www.bababorses.de/Louis-Vuitton-Supreme-Iphone-Case-White-Red-212-it.html https://www.bababorses.de/Louis-Vuitton-Epi-Smooth-Leather-Twist-Shoulder-Bag-MM-Pink-Black-2639-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Empreinte-Leather-Cosmetic-Pouch-Bag-M80502-Bouton-de-Rose-Pink-By-The-Pool-Capsule-Collection-4296-it.html https://www.bababorses.de/Louis-Vuitton-Bracelet-21-271-it.html https://www.bababorses.de/Louis-Vuitton-Heel-9.5-cm-Star-Trail-Ankle-Boots-Black-5511-it.html https://www.bababorses.de/Louis-Vuitton-Geronimos-Belt-Bag-M43502-Black-Epi-Leather-2646-it.html https://www.bababorses.de/Louis-Vuitton-Damier-Ebene-Canvas-Vavin-Chain-Wallet-N60222-Bordeaux-Red-7221-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Empreinte-Leather-Zippy-Coin-Purse-M80408-Cream-Saffron-By-The-Pool-Capsule-Collection-7741-it.html https://www.bababorses.de/Louis-Vuitton-Vintage-Monogram-Vernis-Bleecker-Box-Top-Handle-Bag-Burgundy-4172-it.html https://www.bababorses.de/Prada-Saffiano-Mini-Galleria-Crossbody-Bag-Beige-it-2708 https://www.bababorses.de/Louis-Vuitton-Sunglasses-39-1042-it.html https://www.bababorses.de/Louis-Vuitton-Monogram-Canvas-Leopard-Print-Onthego-Tote-Bag-M44674-Black-White-3232-it.html https://www.bababorses.de/Louis-Vuitton-Epi-Leather-Twist-PM-Bag-with-Crystal-embellished-Chain-M55412-White-2630-it.html https://www.bababorses.de/Fendi-Chameleon-Red-Cross-Veins-Leather-Tote-Bag-it-488 https://www.bababorses.de/Louis-Vuitton-Monogram-Canvas-Onthego-Tote-Bag-M44571-Kaki-3270-it.html https://www.bababorses.de/Fendi-Earth-Yellow-Leather-with-Multicolor-Striped-Fabric-Shopping-Handbag-it-771 https://www.bababorses.de/Louis-Vuitton-Croco-Pattern-Petite-Boite-Chapeau-Bag-Black-4090-it.html https://www.bababorses.de/Prada-Saffiano-Small-Double-Handle-Tote-Bag-Light-Gray-Pomice-it-2849 https://www.bababorses.de/Louis-Vuitton-Lvxlol-Speedy-BB-M45202-Golden-3125-it.html https://www.bababorses.de/Louis-Vuitton-Gloria-Flat-Open-Back-Loafers-Monogram-Canvas-5798-it.html https://www.bababorses.de/LOUIS-VUITTON-BREA-PM-Monogram-Vernis-leather-IN-MORDORE-4074-it.html https://www.bababorses.de/Replica-Hermes-Steve-H2810-Ladies-Shoulder-Bag-Cow-Leather-it-1428 https://www.bababorses.de/Louis-Vuitton-Noe-bag-M42226-Brown-3496-it.html https://www.bababorses.de/Louis-Vuitton-Damier-Azur-Canvas-I-2260-it.html https://www.bababorses.de/Christian-Dior-Multicolor-PeachYellow-Zipper-Wallet-118-it-223 https://www.bababorses.de/Fendi-By-the-Way-Small-Tricolor-Satchel-Bag-it-2916 https://www.bababorses.de/Prada-Medium-Vitello-Diano-Open-Tote-Bag-Pomice-it-2728 https://www.bababorses.de/Luxury-Hermes-Wallet-H001-Unisex-Wallet-it-1598 https://www.bababorses.de/Louis-Vuitton-Iphone-Case-LV42-104-it.html https://www.bababorses.de/Prada-Saffiano-Small-Gardeners-Tote-Bag-Blue-it-2803 https://www.bababorses.de/Louis-Vuitton-Sac-Tricot-Bag-Epi-Leather-Red-M52805-2736-it.html https://www.bababorses.de/Louis-Vuitton-Crazy-in-Lock-Strass-Bracelet-Silver-316-it.html