473,231 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

IE cannot set 'name' attribute on runtime elements created by createElement

checkout: (3rd paragraph under 'Remarks' section)
http://msdn.microsoft.com/library/de...ies/name_2.asp

from the page:
"The NAME attribute cannot be set at run time on elements dynamically
created with the createElement method. To create an element with a
name attribute, include the attribute and value when using the
createElement method."

to work around this you have to code:

document.createElement('<div name="ieiscrap">')

which -surprise- fails in Firefox. i haven't tested in any other
browsers. this one really caused me a headache.

does anyone know why IE does this?

Jun 7 '07 #1
4 11209
Walton wrote:
checkout: (3rd paragraph under 'Remarks' section)
http://msdn.microsoft.com/library/de...ies/name_2.asp

from the page:
"The NAME attribute cannot be set at run time on elements dynamically
created with the createElement method. To create an element with a
name attribute, include the attribute and value when using the
createElement method."

to work around this you have to code:

document.createElement('<div name="ieiscrap">')

which -surprise- fails in Firefox. i haven't tested in any other
browsers. this one really caused me a headache.

does anyone know why IE does this?
window.onload = function()
{
var p = document.createElement('p');
p.appendChild(document.createTextNode('IE Sucks!'));
p.name = 'IE';
document.getElementsByTagName('body')[0].appendChild(p);
}

<p onclick="alert(document.getElementsByTagName('p')[1].name);">show me
the money, er... name</p>

Works in Internet Explorer 6 (and any DOM-compliant/aware browser or
viewing device).

Does this not work in Internet Explorer 7? If so, they regressed.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Jun 7 '07 #2
Walton wrote:
checkout: (3rd paragraph under 'Remarks' section)
http://msdn.microsoft.com/library/de...ies/name_2.asp

from the page:
"The NAME attribute cannot be set at run time on elements dynamically
created with the createElement method. To create an element with a
name attribute, include the attribute and value when using the
createElement method."

to work around this you have to code:

document.createElement('<div name="ieiscrap">')

which -surprise- fails in Firefox. i haven't tested in any other
browsers. this one really caused me a headache.

does anyone know why IE does this?
The key is in the paragraph above the one you referenced:

"Microsoft JScript allows the name to be changed at run time. This does
not cause the name in the programming model to change in the collection
of elements, but it does change the name used for submitting elements."

In other words, IE assigns a "programming model" name attribute when the
control is created and it can't be changed. However, controls seem to
also have a user definable name: if you change the name of the control
programmatically, it is this name that changes, not the "programming
model" name. If you submit the control with the form, the name that is
submitted is the programming model name or the (hidden) user-definable
name if it's been set. The name you set can't be used with the elements
collection, like:

document.form.nameIset

or

document.form.elements['nameIset']
Why is IE like that? Who knows, MS have only had 10 years to fix it,
maybe they like it like it is.
--
Rob
"We shall not cease from exploration, and the end of all our
exploring will be to arrive where we started and know the
place for the first time." -- T. S. Eliot
Jun 8 '07 #3
Does this not work in Internet Explorer 7? If so, they regressed.
yeah, i was using ie7. didn't test in ie6

Jun 8 '07 #4
On Jun 8, 8:22 am, Walton <jrhol...@gmail.comwrote:
Does this not work in Internet Explorer 7? If so, they regressed.

yeah, i was using ie7. didn't test in ie6
I should also be a bit clearer with my example. I was creating form
inputs and selects when running into this issue.

Jun 8 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ivo | last post by:
I have this code to add a row to a table: var r=document.createElement('tr'); var c=document.createElement('td'); var cn=c.cloneNode(false); cn.className='tdname';...
6
by: Martin | last post by:
I am having trouble trying to more closely relate objects (as functions) in javascript with HTML elements. For example, I have an object 'class' MyImage: function MyImage(file) { var img =...
7
by: Christopher J. Hahn | last post by:
I'm trying to use a script-generated form to submit to a script-generated iframe. The problem I'm running into is that the iframe is not assuming the name I assign it. IE6 on Win2000. FF1.0.2+...
7
by: Stefan Mueller | last post by:
How can I set the Name of a button? I tried xelement = document.createElement("input") xelement.type = "button" xelement.name = "MyButton" but it does not work with the Internet Explorer...
5
by: stellstarin | last post by:
I have a html where fields are created and added dynamically on the client side. I use the AppendChild() call to create fields dynamically. On submit i try to get the value for all the...
16
by: TT (Tom Tempelaere) | last post by:
Hi all, I created an XSD to define the structure of an XML file for my project. I made an XML file linked to the XSD using XmlSpy. The problem is that if I read the file using .NET XmlDocument...
6
by: Jakub.Bednarczuk | last post by:
Hallo everybody I have the problem with getting attributes values and also attributes names. I am reading an xml file with DOM. Lets see an example: file I read <root> <Def></Def>...
3
by: deaddog4201 | last post by:
How can i save a .txt file where the name of the file would be the result of the selection made from a Dom tree view's parent node tag in visual basic? So for example i have an editable tree view...
4
by: =?Utf-8?B?VG9yZW4gVmFsb25l?= | last post by:
Was editing code, am getting the following errors } expected Type or namespace definition, or end-of-file expected Eyes crossed cannot find code below! using System; using...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.