This is mostly just a place for me to keep track of code snippets.
Note that the sample code illustrates how to do something; wholesale copy and paste may not work.
Double-clicking a code box will select all of the code.
Links and forms followed byOpens in new window will open in a new window.

§ Most important things to remember

"Keep It Simple Stupid!"  (KISS principle)

"If it ain't broke, don't fix it!"

(Remember, this is mostly for me; I'm not trying to call you stupid.)

0 Comments added to this post

§ Helpful links

If you're looking at this blog, I hope you are already familiar with these sites:

 

w3schools.com explains how things work with try it yourself examples.

 

quirksmode.org explains why things don't work in your browser.

 

Another site you might like is Jakob Nielsen's useit.com.  It has a lot of advice focused on usability.  I like this bit:

Jakob's Law of the Web User Experience states that "users spend most of their time on other websites."

The point being that if you make a really nifty design with really cool effects, but visitors can't find the scroll bar or tell if something is a link or not, they won't stick around.  You may have really impressed them, but not the way you intended...

 

When I search google and find myself on the same page... again... I'm putting a link here!

Add and Remove Elements with JavaScript (reprise)  Thank you Dustin Diaz!

Regular Expression Quick Start from regular-expressions.info.

A gold mine of articles from Mitchell Harper at Dev Articles.  Hasn't been updated for a while, but the information is just as true today.

Doctypes at w3.org.

What's the deal with document.documentElement?  I thought it was document.body...  More doctype issues, especially good ol' IE, at document.body, doctype switching, and more.

Good gosh, how many times have I looked at this page:  $_SERVER[’PHP_SELF’], $_SERVER['REQUEST_URI'], and $_SERVER[’SCRIPT_NAME’]?

 

0 Comments added to this post

§ Avoid email harvesting with javascript

I don't like to put real email addresses on web pages because "harvesters" look for them to add to their spam list.  However, harvesters probably don't run javascript before searching.

Read More ...

§ IE App Compat VHD

Download Virtual PC VHD files (virtual hard drive) with XP or Vista and IE6, IE7, or IE8 at:

http://www.microsoft.com/downloads/details.aspx?FamilyId=21EABB90-958F-4B64-B5F1-73D0A413C8EF&displaylang=en

These expire periodically; the download page tells you when it will expire.  Microsoft links change all the time, so you may have to search instead.

You also need Virtual PC, a free download from Microsoft.

0 Comments added to this post

§ External links to new windows

Ok, there's lots of REALLY HEATED discussions about this topic all over the web.  I'm not looking for arguments; I'm just posting what I do here in this blog.

Read More ...

§ Format apache directory listing

The default directory listing apache shows is controlled by mod_autoindex and it has some options available.

Read More ...

§ My XP startup items

I have a couple of shortcuts in my startup folder.  These are the "Target" lines of the shortcuts.

The first one gets rid of explorer's showing every zip file as a folder.  You know how many zip files I've got?  The /s at the end makes it not show a dialog box when it's finished.

%windir%\system32\regsvr32.exe /u zipfldr.dll /s

The second maps w: to my localhost root.  Good ol' DOS commands!

%windir%\system32\subst.exe w: e:\wamp\www

0 Comments added to this post

§ Simple AJAX request

Almost all of my AJAXing is to simply grab the output of a source and stuff it in in a div.  In previous posts you can see what I've been using for a long time, but I wanted to make a function I wouldn't have to edit every time I used it in a project.

Read More ...

§ Validating email addresses (it's impossible) (Rant Alert!)

Search google for "validate email address" and you'll get about 303,000 results.  I bet all of them are wrong...

Short version:

Why bother?  I'm probably going to enter "example@example.com" anyway.

Read More ...

§ Adding & removing element classnames

A couple of ways to change classnames of elements.

Read More ...

§ Table row hover highlight

A bit of javascript to highlight the table row under the cursor.

Read More ...

§ Handling url get string with javascript

Using javascript to handle url get string variables

Read More ...

§ Better tabbed interface

Tabbed interface using get string to set active tab.

Read More ...

§ Auto replace textareas with fckeditor

Simple function to replace any textarea with fckeditor.

Read More ...

§ Simpler validate form fields are filled in (no additional class names)

Makes sure something is entered in form fields.  If your form fields have classnames, don't use this one!

Read More ...

§ Validate form fields are filled in (additional class names)

Makes sure something is entered in form fields.  Uses regex to replace classnames so other classnames aren't affected.

Read More ...

§ Javascript function to add css

This javascript is a way to add an extra style node (css) into a page.

Read More ...

§ setInterval to stay logged in

Just a setInterval example to refresh a page.

Read More ...

§ Adding events to elements

For most elements, you can just do element.onclick = function_name.  But read on...

(Much better article available at Add and Remove Elements with JavaScript (reprise) from Dustin Diaz.)

Read More ...

§ Image tabbed interface controlling hidden divs

Tabbed interface using images for rounded tabs.  Gives decent results even if javascript and/or css are off.

Read More ...

More entries...


“If everybody minded their own business,” said the Duchess in a hoarse growl, “the world would go round a deal faster than it does.”
Lewis Carroll, quoted in To Say Nothing of the Dog, Connie Willis