Categories
Professional

CSS Genius at work.

And no, it’s not me.  Someone sent me a link to Matthew James Taylor’s “Equal Height Columns with Cross Browser CSS” post.  It’s a really smooth way to get equal height columns with different backgrounds working smoothly.

Since reading this first post, I’ve spent several hours reading through what he has on his site; some if it’s quite ingenious and I must say I’m quite jealous that I haven’t come up with some of the ideas myself.  And the best part of it all, it’s all there for download and use… not that an intelligent person could scrape the CSS and HTML to replicate what he’s doing anyhow, but it’s nice to know he’s willing to share.  So I encourage to go off and learn, be inspired.  I know I’m inspired and looking at doing a redesign based off of what I’ve read so far.  My hat’s off to you Matthew James Taylor.

Categories
Professional

Ah, the power of JavaScript

I was asked about creating a javascript that would place an image on a page based on the day of the week. Easy enough right? Well, it took some tinkering, but here it is (http://www.servergoon.com/samples/dow/). For this demonstration I created eight images, each with the number 0 – 7. However, since the javascript Date Object returns 0 – 6, you will never see the 7.

The code for this is relatively simple, as you can see if you look at the source for this file. In the head I’ve preloaded the image, which, from what I can tell is necessary. Second I’ve got all of the files I want and named them the same, with the exception of the digit indicating the Day of the Week. Hence the DOW (stands for Day Of Week) for the name followed by a digit followed by .jpg. This is so I don’t have to write out 8 (or 31 if you were ambitious enough to do this for each Day Of the Month) individual lines (actually it would be more like 16 lines). It also makes the code to replace the image much easier and shorter to write as well.

The JavaScript in the head of the document looks like:

<SCRIPT language="JavaScript">
<!--
if (document.images)
{
	document.pics = new Array();
	for (j=0; j<8; j++) {
		document.pics[j] = new Image;
		var imageName = "DOW" + j + ".jpg";
		document.pics[j].src = imageName;
	}
}

//-->
</SCRIPT>

The code for the image is below, notice the ID tag, this is VERY important.  Notice that there is no source file, so no image is loaded by default

<img id="DayOfWeek" src="" height="50px" width="50px" border="1"/>
<img id="DayOfWeek2" src="" height="50px" width="50px" border="1"/>

And finally, the code to replace the images in the HTML code.

<script type="text/javascript">
   var myDate = new Date();
   var DOW = myDate.getDay();
   document.getElementById('DayOfWeek').src = document.pics[DOW].src;
   document.getElementById('DayOfWeek2').src = document.pics[DOW+1].src;
</script>

One more thing to note is that the JavaScript that changes the image needs to come AFTER the image in HTML code. If not, it doesn’t know about the image and can’t replace it. The other option would be to put the code in the head of the HTML file and trigger it with a function call.

I hope you found this useful, I know I can think of uses for this.  As always your mileage may vary.

Categories
Interests

funerals

Just for the record, I hate funerals.

Death is a miserable fact of life and one that we all must face. I don’t look forward to the time when my Dad will pass away.  However, I have had the honor of living long enough to develop a good relationship with my dad. A good enough relationship with him that we’ve had the discussions about how he feels about prolonging life after the quality of life is gone. We’ve also had a discussion about funerals so what happened today really shouldn’t surprise me.

You see, my Aunt died recently, and today was her funeral. The person officiating the ceremony seemed a little nervous, perhaps it was his first funeral. At any rate, as he was wrapping up the ceremony, my father leaned over to a long time friend and said “When you officiate my funeral I want you to say ‘He lived fast, hard and enjoyed every minute of it… and then he died'” -edit- Just to be clear, my Dad doesn’t live fast, he’s one of the calmest people I know, thinking through things instead of spur of the moment actions.  My Dad doesn’t “live hard”, although I’m sure he’s experiences hard times.  But I do know my Dad has enjoyed his life and continues to do so. His statement was an indication of how much time he thought should be spent on a funeral. He told me one time that what he wanted in his obituary was simply a listing of born, husband of, father of and died. -edit-

There are many reasons I love my dad, and that is one of them.