Removing NAME attritbute

A

Andrew Poulos

I've been given a large number of HTML pages. Each page has one or more
tags. When the pages were being built I asked that an ID attribute be
included with each element that will later be referenced. The first
ID'ed element on the page has the ID 'item0', the next 'item1' and so on.

Unfortunately they also included a NAME element which in many cases is
similar to the ID but out by one. That is the first element on the page
has the NAME 'item1', the next 'item2' and so on.

This stuffs up some things that depend on the ID (IE seems to make use
of the NAME instead of the ID when I ask getElementByID). Is there an
"easy" way to remove all the NAME attributes, or at least make them
invisible to IE, on page load?

Andrew Poulos
 
V

VK

Andrew said:
Is there an
"easy" way to remove all the NAME attributes, or at least make them
invisible to IE, on page load?

You may iterate through document.all collection and
removeAttribute('NAME'). I don't know if IE supports the mask
document.getElementsByTagName("*") // all elements
but you can try also. Yet you cannot kill every single NAME on the page
as it breaks form submission (if presented), you need to check element
type before removal.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,128
Latest member
ElwoodPhil
Top