rubikzube

software engineer ¤ yogi ¤ turban cowboy

Wednesday, April 06, 2005

Now that's freaky

When writing some JavaScript today I found some interesting browser behavior I thought I would share. The following script generates two different behaviors in Firefox and Internet Explorer…

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Keywords" CONTENT="">
</HEAD>
<BODY>
<INPUT TYPE="text" NAME="keywords" ID="keywords"/>
<script language="javascript">
<!--
alert(document.getElementById("keywords"));
//-->
</script>
</BODY>
</HTML>


This statement returned the <META> at the top of the page in Internet Explorer, while in Firefox it returned the <INPUT>. So which one is more technically correct? My gut would say that Internet Explorer overleapt its responsibilities by returning me an element that I had not specifically identified as "keywords", but the leap itself was damn cool.

0 Comments:

Post a Comment