<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Setting the &#8220;name&#8221; attribute in Internet Explorer</title>
	<atom:link href="http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/</link>
	<description>Software, the Internet and you.</description>
	<pubDate>Mon, 12 May 2008 16:13:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: tiago.santos</title>
		<link>http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/#comment-46734</link>
		<dc:creator>tiago.santos</dc:creator>
		<pubDate>Fri, 22 Feb 2008 17:36:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.thunderguy.com/semicolon/20050511/42/#comment-46734</guid>
		<description>To set an attribute 
I use getAttribute("XXX").value.

ex:
var pass = document.getElementById('txtPassword');					pass.getAttribute("onfocus").value = "javascript:blabla()";

Tested and worked on FF, IE7, IE6, IE5.5 ....</description>
		<content:encoded><![CDATA[<p>To set an attribute<br />
I use getAttribute(&#8221;XXX&#8221;).value.</p>
<p>ex:<br />
var pass = document.getElementById(&#8217;txtPassword&#8217;);					pass.getAttribute(&#8221;onfocus&#8221;).value = &#8220;javascript:blabla()&#8221;;</p>
<p>Tested and worked on FF, IE7, IE6, IE5.5 &#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harvey</title>
		<link>http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/#comment-45822</link>
		<dc:creator>Harvey</dc:creator>
		<pubDate>Sun, 10 Feb 2008 04:19:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.thunderguy.com/semicolon/20050511/42/#comment-45822</guid>
		<description>Although still far from perfect, this would be a better solution, only applying the hack to IE, and letting the other browsers work as designed:

var isOpera, isIE = false;
if(typeof(window.opera) != 'undefined'){isOpera = true;}
if(!isOpera &#38;&#38; navigator.userAgent.indexOf('Internet Explorer')){isIE = true);

function createNamedElement(type, name, checked){
  var element = document.createElement(type);
  if(name){
    element.setAttribute('name', name);
  }
  if(checked){
    element.setAttribute('checked', 'checked');
  }
  return element;
}

//fix IE
if(isIE){
  function createNamedElement(type, name, checked){
    var elemStr = '';
    return document.createElement(elemStr);
  }
}

With this, the function is redefined if IE, to handle its broken DOM.</description>
		<content:encoded><![CDATA[<p>Although still far from perfect, this would be a better solution, only applying the hack to IE, and letting the other browsers work as designed:</p>
<p>var isOpera, isIE = false;<br />
if(typeof(window.opera) != &#8216;undefined&#8217;){isOpera = true;}<br />
if(!isOpera &amp;&amp; navigator.userAgent.indexOf(&#8217;Internet Explorer&#8217;)){isIE = true);</p>
<p>function createNamedElement(type, name, checked){<br />
  var element = document.createElement(type);<br />
  if(name){<br />
    element.setAttribute(&#8217;name&#8217;, name);<br />
  }<br />
  if(checked){<br />
    element.setAttribute(&#8217;checked&#8217;, &#8216;checked&#8217;);<br />
  }<br />
  return element;<br />
}</p>
<p>//fix IE<br />
if(isIE){<br />
  function createNamedElement(type, name, checked){<br />
    var elemStr = &#8221;;<br />
    return document.createElement(elemStr);<br />
  }<br />
}</p>
<p>With this, the function is redefined if IE, to handle its broken DOM.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bert Zwep</title>
		<link>http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/#comment-43803</link>
		<dc:creator>Bert Zwep</dc:creator>
		<pubDate>Tue, 15 Jan 2008 14:28:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.thunderguy.com/semicolon/20050511/42/#comment-43803</guid>
		<description>@Pablo

You can not set an onclick on an element in IE as an attribute. This is because IE does not see it as an attribute, but as an object. Try e.g.:
eval("elem.onclick='myScript()'")</description>
		<content:encoded><![CDATA[<p>@Pablo</p>
<p>You can not set an onclick on an element in IE as an attribute. This is because IE does not see it as an attribute, but as an object. Try e.g.:<br />
eval(&#8221;elem.onclick=&#8217;myScript()&#8217;&#8221;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Murphy</title>
		<link>http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/#comment-43690</link>
		<dc:creator>Matt Murphy</dc:creator>
		<pubDate>Sun, 13 Jan 2008 23:46:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.thunderguy.com/semicolon/20050511/42/#comment-43690</guid>
		<description>I think I may have found another way around this bug.

I posted the solution I found on my web development blog here:
http://matts411.com/webdev/cre.....javascript

Let me know what you guys think.

Matt</description>
		<content:encoded><![CDATA[<p>I think I may have found another way around this bug.</p>
<p>I posted the solution I found on my web development blog here:<br />
<a href="http://matts411.com/webdev/cre.....javascript" rel="nofollow">http://matts411.com/webdev/cre&#8230;..javascript</a></p>
<p>Let me know what you guys think.</p>
<p>Matt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ttnet mp3</title>
		<link>http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/#comment-43161</link>
		<dc:creator>ttnet mp3</dc:creator>
		<pubDate>Thu, 03 Jan 2008 17:59:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.thunderguy.com/semicolon/20050511/42/#comment-43161</guid>
		<description>//if the ‘error’ was not set, as in IE:
var el2= document.createElement(’span’);
var str= ”;
pa.replaceChild(el2,el);
return el2.firstChild;
}</description>
		<content:encoded><![CDATA[<p>//if the ‘error’ was not set, as in IE:<br />
var el2= document.createElement(’span’);<br />
var str= ”;<br />
pa.replaceChild(el2,el);<br />
return el2.firstChild;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ttnet müzik</title>
		<link>http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/#comment-43160</link>
		<dc:creator>ttnet müzik</dc:creator>
		<pubDate>Thu, 03 Jan 2008 17:57:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.thunderguy.com/semicolon/20050511/42/#comment-43160</guid>
		<description>error S:</description>
		<content:encoded><![CDATA[<p>error S:</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mrHoo</title>
		<link>http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/#comment-39751</link>
		<dc:creator>mrHoo</dc:creator>
		<pubDate>Thu, 25 Oct 2007 17:24:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.thunderguy.com/semicolon/20050511/42/#comment-39751</guid>
		<description>/* 
This seems to work to create new input elements across browsers, but I welcome your opinions.
parameters: (pa) a reference to the parent node of the new input, and (attr) an attributes object.
*/
 
function Fieldname(pa,attr){
	var el= document.createElement('input');
	for(var p in attr) el[p]= attr[p];
	pa.appendChild(el);
	if(el.name) return el;

//if the 'name' was not set, as in IE:
	var el2= document.createElement('span');
	var str= '';
	pa.replaceChild(el2,el);
	return el2.firstChild;
}
//test case
var el= new Fieldname(document.body, 
{type:'text', name:'newInput', size:'10',
onchange:function(){alert(this.name)}})

//In practice, the first parameter would refer to a label or fieldset or form element</description>
		<content:encoded><![CDATA[<p>/*<br />
This seems to work to create new input elements across browsers, but I welcome your opinions.<br />
parameters: (pa) a reference to the parent node of the new input, and (attr) an attributes object.<br />
*/</p>
<p>function Fieldname(pa,attr){<br />
	var el= document.createElement(&#8217;input&#8217;);<br />
	for(var p in attr) el[p]= attr[p];<br />
	pa.appendChild(el);<br />
	if(el.name) return el;</p>
<p>//if the &#8216;name&#8217; was not set, as in IE:<br />
	var el2= document.createElement(&#8217;span&#8217;);<br />
	var str= &#8221;;<br />
	pa.replaceChild(el2,el);<br />
	return el2.firstChild;<br />
}<br />
//test case<br />
var el= new Fieldname(document.body,<br />
{type:&#8217;text&#8217;, name:&#8217;newInput&#8217;, size:&#8217;10&#8242;,<br />
onchange:function(){alert(this.name)}})</p>
<p>//In practice, the first parameter would refer to a label or fieldset or form element</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jobin Basani</title>
		<link>http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/#comment-36786</link>
		<dc:creator>Jobin Basani</dc:creator>
		<pubDate>Mon, 03 Sep 2007 11:27:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.thunderguy.com/semicolon/20050511/42/#comment-36786</guid>
		<description>It works...!  I was having trouble accessing the dynamically created form elements...Well,it's solved now..Thanks!</description>
		<content:encoded><![CDATA[<p>It works&#8230;!  I was having trouble accessing the dynamically created form elements&#8230;Well,it&#8217;s solved now..Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nj</title>
		<link>http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/#comment-36642</link>
		<dc:creator>nj</dc:creator>
		<pubDate>Fri, 31 Aug 2007 22:54:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.thunderguy.com/semicolon/20050511/42/#comment-36642</guid>
		<description>Bless you for this article! and Thanks a ton!</description>
		<content:encoded><![CDATA[<p>Bless you for this article! and Thanks a ton!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bennett</title>
		<link>http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/#comment-35538</link>
		<dc:creator>Bennett</dc:creator>
		<pubDate>Fri, 10 Aug 2007 10:39:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.thunderguy.com/semicolon/20050511/42/#comment-35538</guid>
		<description>It has just occurred to me that the function as written may not work if your page is served as application/xhtml+xml. I haven't tested it, but it seems to me that if your page is served as application/xhtml+xml then you should remove the ".toUpperCase()" from the function.

If you try this, please let me know how it turns out.</description>
		<content:encoded><![CDATA[<p>It has just occurred to me that the function as written may not work if your page is served as application/xhtml+xml. I haven&#8217;t tested it, but it seems to me that if your page is served as application/xhtml+xml then you should remove the &#8220;.toUpperCase()&#8221; from the function.</p>
<p>If you try this, please let me know how it turns out.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
