Need/Want to Hide Internet Explorer 6 Specific JavaScript from IE7?

I use conditional comments to hide IE6 specific styles and scripts from IE7 (and IE7 specific styles and scripts from other browsers), but sometimes you need a bit of logic or something to only run on IE6 and earlier. Conditional compilation is a pretty foolproof way to handle that.

function ie_function() {
/*@cc_on @*/
/*@if (@_jscript_version < 5.7)
do_ie_6_stuff()
/*@end @*/
}

the @cc_on block turns on conditional compile. Since it’s wrapped in a comment block every other browser just ignores it. The next line (@if (@_jscript_version < 5.7)) tests for the specific JScript version present in IE7. If it’s there, nothing else happens. Otherwise the code on the next line is run. Wicked. Flip the comparison operator to >= and you’ve got a foolproof test for IE7. Double wicked.

Code : Javascript : Turn a block into a clickable link area.

Here’s a little script (and some CSS) that turns an entire block (in this case a TR) into a click-able item:
Continue reading “Code : Javascript : Turn a block into a clickable link area.”

Cross Browser PNG Transparency

(I wrote this post at my old job. Since IE6 will be around for some time to come, the techniques in use here are still useful going forward as more and more designers are going to want to use Transparent PNGs in their designs. I’m going to add onto this article at some point in the near future to fully flesh out all the possibilities. See PART 2 of this article)
Continue reading “Cross Browser PNG Transparency”

Javascript: Parse Domain Name out of a String

Did I mention that the “Web” category might contain code? It might. In fact, it will.

Here’s a random function I wrote last night that might be useful


function getDomain (thestring) {
//simple function that matches the beginning of a URL
//in a string and then returns the domain.
var urlpattern = new RegExp("(http|ftp|https)://(.*?)/.*$");
var parsedurl = thestring.match(urlpattern);
return parsedurl[2];
}

Is there a better way to do that? I don’t know. The momentum of “I’ve got to get this done”, got in the way and left me with the above function.