473,386 Members | 1,791 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,386 software developers and data experts.

Automatic tag variables in IE

acw
I am trying to understand how IE handles automatic tag variables.

I know that IE will create a global variable each time it finds a tag
with its name or id attribute set. If you have more than one tag with
the same name or id (yes this is bad) on a page then that global
variable goes from being a tag reference to being a collection of
references.

In most cases if you remove the duplicate tag the global var becomes a
tag reference again. Other times it remains a collection but with only
one element.

Getting completely away from using the automatic variables is not an
option. So, I am trying to understand how the variables are handled by
IE. Does anyone know what determines whether the global variable is
reverted to a tag reference or left as a collection when the duplicate
tags are removed from the page?
================================================== ==========

For example, if we start with
..
<div id="container1"></div>
<div id="container2"></div>
..

then do ...

..
container1.innerHTML = "<span id='sometext'>some text</span>"
....
container2.innerHTML = "<span id='sometext'>some more text</span>"
..

The global var sometext is a collection with two elements.
If we do the following
container2.innerHTML = ""
The global var sometext is usually pointing to the first span. Other
times is a collection and sometext[0] points to the first span.


TIA!
Jul 2 '08 #1
4 1689
acw wrote:
I am trying to understand how IE handles automatic tag variables.

I know that IE will create a global variable each time it finds a tag
with its name or id attribute set. If you have more than one tag with
the same name or id (yes this is bad) on a page then that global
variable goes from being a tag reference to being a collection of
references.

In most cases if you remove the duplicate tag the global var becomes a
tag reference again. Other times it remains a collection but with only
one element.

Getting completely away from using the automatic variables is not an
option. So, I am trying to understand how the variables are handled by
IE. Does anyone know what determines whether the global variable is
reverted to a tag reference or left as a collection when the duplicate
tags are removed from the page?
================================================== ==========

For example, if we start with
.
<div id="container1"></div>
<div id="container2"></div>
.

then do ...

.
container1.innerHTML = "<span id='sometext'>some text</span>"
...
container2.innerHTML = "<span id='sometext'>some more text</span>"
.

The global var sometext is a collection with two elements.
If we do the following
container2.innerHTML = ""
The global var sometext is usually pointing to the first span. Other
times is a collection and sometext[0] points to the first span.
The flaw is in a document all IDs must be unique, and IDs cannot be
arrays...
--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Jul 2 '08 #2
acw
Jonathan,

Thanks for the response.

Yes ids do need to be unique. In this case that are not and, because
of the nature of the project, I am not in a position to make them
unique.
I am really just wanting to understand how IE handles the automatic
vars.
TIA


On Jul 2, 1:25*pm, "Jonathan N. Little" <lws4...@central.netwrote:
acw wrote:
I am trying to understand how IE handles automatic tag variables.
I know that IE will create a global variable each time it finds a tag
with its name or id attribute set. If you have more than one tag with
the same name or id (yes this is bad) on a page then that global
variable goes from being a tag reference to being a collection of
references.
In most cases if you remove the duplicate tag the global var becomes a
tag reference again. Other times it remains a collection but with only
one element.
Getting completely away from using the automatic variables is not an
option. So, I am trying to understand how the variables are handled by
IE. Does anyone know what determines whether the global variable is
reverted to a tag reference or left as a collection when the duplicate
tags are removed from the page?
================================================== ==========
For example, if we start with
.
<div id="container1"></div>
<div id="container2"></div>
.
then do ...
.
container1.innerHTML = "<span id='sometext'>some text</span>"
...
container2.innerHTML = "<span id='sometext'>some more text</span>"
.
The global var sometext is a collection with two elements.
If we do the following
container2.innerHTML = ""
The global var sometext is usually pointing to the first span. Other
times is a collection and sometext[0] points to the first span.

The flaw is in a document all IDs must be unique, and IDs cannot be
arrays...

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIOhttp://www.LittleWorksStudio.com- Hide quoted text -

- Show quoted text -
Jul 2 '08 #3

acw wrote:
I am trying to understand how IE handles automatic tag variables.
I suggest asking Microsoft how their browser works because I doubt very
many people here know or care. The IE groups are over at
microsoft.public.<something about IE>

--
Berg
Jul 2 '08 #4
acw wrote:
Jonathan,

Thanks for the response.

Yes ids do need to be unique. In this case that are not and, because
of the nature of the project, I am not in a position to make them
unique.
Well that make the document invalid, then who knows? Computers like
"Yes|No", when you throw "Maybe" at them then it is up how well of an
exception handler you got...

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Jul 2 '08 #5

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

Similar topics

1
by: Anthony Martin | last post by:
I've been reading the Java Language Specification, and in Chapter 16 there's an interesting topic called Definite Assignment. http://tinyurl.com/3fqk8 I'm wondering about the idea of "Deferred...
5
by: cedric buerfent | last post by:
Hello NG, I ve a question concerning automatic generated source code. When I program the declarations of a class (and save it in a file called myclass.hh for example), its a boring work to...
6
by: main() | last post by:
I'm a newbie. These questions arose out of my curiosity, Please pardon me if this questions sound silly. 1. Why are the automatic variables are left uninitialized by default( as i understand...
58
by: Jorge Peixoto de Morais Neto | last post by:
I was reading the code of FFmpeg and it seems that they use malloc just too much. The problems and dangers of malloc are widely known. Malloc also has some overhead (although I don't know what is...
25
by: sidd | last post by:
In the following code: int i = 5; ---it goes to .data segment int j; ---it goes to bss segment int main() { int c; int i = 5; ---stack
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.