Chrome CSS Drop Down Menu Offsets with Centered Pages

I decided to try Chrome CSS Menu on a project I'm working on. While I'd love a pure CSS solution, I don't have time to roll my own, and everything I saw relies on fixed width parent elements. The Chrome menu is very easy to drop into your existing CSS html.

The one problem I had was using this menu with a fixed-width, centered page. For example, a 900 pixel wide page, centered:

<style>
div#ie_fix {
text-align:center;
}

div#container {
   margin: 0 auto 0 auto;
   text-align: left;
   width:900px;
   position:relative;
   }
</style>

<div id="ie_fix">
<div id="container">
***MAIN PAGE GOES HERE***
</div>
</div>

I really needed that container div to be positioned relative, and that was making the drop down menu offsets off by whatever the left page margin happened to be.

My solution was to change (hack) the chrome.js file to stop spidering up the parent elements when it hit that container div.

Make this:

while (parentEl!=null)

Into this:

while (parentEl!=null && parentEl.id!='container')

fckeditor and AJAX

fckeditor is cool, and so is AJAX. I've never used them together until today, and it's quite simple.

One gotcha that was killing me - if/when you use Javascript to send the contents of the fckeditor window, keep these few things in mind (for use with ColdFusion, BTW):

  • Assuming you have a submit button that sends the contents to a JS function, use this to grab that content:
    FCKeditorAPI.GetInstance('myInstance').GetXHTML());
  • And if/when you send your data from JS to CF, be sure to use the javascript encode function:
    var foo = encode(FCKeditorAPI.GetInstance('myInstance').GetXHTML()));
  • And if/when you use CF to work with that data, decode it with urldecode:
    <cfset fixedContent = urldecode(incomingData)>

Editing single files with cfEclipse

One thing that kind of bugged me with Eclipse is that I thought I could only edit code contained in a project.

What if you want to edit some standalone file somewhere? I thought I was out of luck. Then I stumbled upon the File Explorer tab (window -> show view -> file explorer view).

You can navigate to any file and edit it, without that file being included in an Eclipse project.

It's probably common knowledge, but I didn't know...

Nested Query Loops - Worst code ever

I had no idea how bad nested query loops are. But oh man, they are BAD.

I came across this "technique" this week when a very busy site started resonding extremely slowly - like 30 seconds per request, sometimes more. I didn't write the code, but I "got" to fix it.

Check this out, if you have a strong stomach:

[More]

Keep it scalable, kids

We had a lot of trouble today with some really bad code that looked to be written about 10 years ago.

It was simply horrible. Nested loops, tons of CFIFs, you name it. Opening and editing this one CF file felt kinda like fixing a leaky pipe in my crawlspace. Dusty air, spiders all over the place, dark, no room to move...yuck.

Anyway this one page suddenly became very popular, and was definately NOT scalable. I rewrote it so the server would stop crashing (!) and it is now seriously about 100 times faster than before.

If, by chance, you are a person looking for web development services, be sure to get someone who knows what they're doing.

If, by chance, you are a developer, make your code scalable. Most of you know this, but I'll say it anyway -- Just because your code runs well on your dev box, it doesn't mean it will perform the same way when it's hit by 50 concurrent users. And if you have to write nasty slow code, at least cache it.

Thanks, I'm going to bed now.

International Characters in DB from CF 4.5

Every now and then you get a little job that seems simple and straight forward, but is anything but. I just encountered one of those.

I recently inherited an old CF application, written in CF 4.5 or 5.0.

The cfml templates have Japanese characters simply pasted in the file, with a meta tag in the HEAD section of the HTML that sets the character set to x-sjis (shift japanese).

[More]

SES can cause trouble if you're not careful

So I recently deployed some SES URL code to a big site we did. One thing I forgot to do was adjust a layout file that is used by sort of sister site - same content, different layouts.

Anyway, I did not add the BASE HREF tag to this layout file. The layout file uses about 50 images or so, all called via a virtual directory.

<img src="myDir/whatever.gif">

Since I forgot to add a BASE HREF, each image call was preceded with the entire SES url:

So each image request actually called a page of the site! Worse yet, the code took MYDIR as a url parameter, which caused the code to throw an error (an unexpected value).

So each page request was throwing about 50 or so errors, each of which resulted in a robust error report sent to my inbox. I'm still getting email messages 30 minutes later. Ugh.

SES lives on

I've done a lot of work with SES, (Search Engine Safe) URLS in the past. I new project has recently required I use them again.

This client knows a lot about Google placement so it's quite interesting. We'll see how they work.

Changes will probably be made to the red viper systems and green viper systems websites based on the lessons learned here.

See here for our sesConverter stuff, or see it in action.

base href breaks javascript form submit

I placed a BASE HREF tag in my application the other day. To my dismay, it somehow screwed up all of my links that submit a form. For example:

<a href="#" onclick="document.theForm.submit();">

I still am not sure what the issue is. I worked around it fairly easily so I guess I'll put off investigation for when I have the time.

But it's a very irritating little problem that took a while to diagnose.

<TBODY> is handy

TBODY? I never used it before. I thought it was just something Dreamweaver put in HTML for some reason.

But the other day, TBODY came in handy. I used it to make a quick and dirty blowout user interface like this:

[+] Thing 1

The code is very simple - and I got to finally use TBODY:

[More]

RegEx Backreferences

Backreferences are cool, but I've never needed to use them before.

I just ran into something where they were quite handy.

I had to manipulate a string like the following:

TNF S/S VENT POLY SHIRT W

The end goal was to see if the string had either a S/S or L/S in it, along with SHIRT. If both substrings were found, remove SHIRT and move the S/S or L/S to the end of the string.

It's not hard, but a one liner kind of is. Backreferences really helped out here.

[More]

CF Loop Bug

I've seen this numerous times throughout the years but I've never actually written it down.

When you do a CFLOOP within a query loop, odd things occasionally happen.

For example:

<cfoutput query="getWidgets">
<select name="whatever">
<cfloop query="getThings">
      <option value="#getThings.ID#" <cfif getThingsID EQ getWidgets.ThingID>selected </cfif>>#getThings.Name#</option>
</cfloop>
</select>
</cfoutput>

The value for getWidgets.ThingID will be lost!

So you have to patch it up like so:

<cfoutput query="getWidgets">
<select name="whatever">

<!--- This line will fix the problem --->
<cfset foo = getWidgets.thingID>

<cfloop query="getThings">
      <option value="#getThings.ID#" <cfif getThingsID EQ foo>selected </cfif>>#getThings.Name#</option>
</cfloop>
</select>
</cfoutput>

This happens in pretty much all versions of CF I've tested on, including v7.

I don't think this happens EVERY time, just in certain situations. Irritating? Hell yeah.

Adding Line Breaks for Printed Media

CSS gives us a nice way to insert line breaks into HTML with page-break-before and page-break-after.

Here's a pretty self explanitory example below. Looks normal in the browser, but when you print the HTML, line breaks are there.

<html>
<head></head>
<body>
This is the first page
<br style="page-break-before:always;">
This is the second page
<br style="page-break-after:always;">
This is the last page
</body>
</html>

Better Radio Buttons

A simple trick to make clicking on the text of a radio button select it. If you don't already know it, you should! Here, try it out:

<label for="FU1"><input type="radio" name="myButton" value="myValue" id="FU1">FUblog 1</label>

Homesite bug

There exists a horrible but known bug in Macromedia Homesite. We've known about it for a long time, but it got me again last night so I thought I'd mention it for all you old timers still using this editor.

[More]

IE form field madness

This totally drove me nuts!

Cut/Paste this code:

<div id="banner">
   <ul>
      <li><a href="#">My account</a></li>
      <li><a href="#">Order status</a></li>
      <li><a href="#">Wish list</a></li>
      <li><a href="#">My cart</li>
   </ul>
</div>

<form>
   <input type="text" size="20" name="whatever">
</form>

Then open it up in IE. Type something into the input box and then try to select your text. Good gravy!

Moral of the story - close your <a> tags (the last LI is missing a </a>). Did you see it? I didn't. For a few minutes, I thought I was going to totally flip out.

TITLE is cool, part 2

David Huyck posted a comment about Javascript tool tips being a good alternative to the CSS/Title solution.

I've never used them before, but they proved to be quite handy. Here's a link to the one I decided to use in a project where I needed response time to be immediate.

Not as elegant as a CSS only solution, but it works, and you can modify the CSS to customize the appearance of the tips.

TITLE is cool

In IE, when you mouse over an image with an ALT parameter, you'll see that text pop up after a brief delay.

CSS lets you do something similar with just about anything - a table cell, span tag, link, etc. Here's a simple example:

[More]

CSS and you

I think this is as good a post as any to begin a blog category on CSS. If you haven't yet embraced CSS yet in full, you might want to read on.

About a year ago, I started a small project and decided to completely dive in to CSS, making all code output completely with DIV, SPAN and P tags. Though the temptation to use a table here and there was strong, I used CSS to control the layout. I'd of course used CSS before, but only for trivial things like link colors, font settings, element borders, etc.

If you're thinking of diving in, here's a few observations that might make your life easier:

[More]


Psykel blog uses BlogCFC (by Raymond Camden). Layout design inspired by arcsin