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

Get all elements in firefox

Does anyone knows, how to all the list of all the elements on the web
page using javascript.
Oct 3 '08 #1
5 6728
Sunny wrote:
Does anyone knows, how to all the list of all the elements on the web
page using javascript.
document.getElementsByTagName('*')
should give all elements in the document. Assuming "web page" is an HTML
document and you want the elements in the body then you might only want
to look in the body e.g.
document.body.getElementsByTagName('*')

--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 3 '08 #2
On Oct 3, 12:58 pm, Martin Honnen <mahotr...@yahoo.dewrote:
Sunny wrote:
Does anyone knows, how to all the list of all the elements on the web
page using javascript.

document.getElementsByTagName('*')
should give all elements in the document. Assuming "web page" is an HTML
document and you want the elements in the body then you might only want
to look in the body e.g.
document.body.getElementsByTagName('*')

--

Martin Honnen
http://JavaScript.FAQTs.com/
When I do:
alert(document.getElementsByTagName('*'));
It gives me "Object HTML Collection"
I want to see, all the elements name in my web page.
As I am creating some elements dynamically, i want the name of all the
elements present on my webpage.
And I want to do that in Firefox.
Any solution.
Oct 3 '08 #3
Sunny <su**********@gmail.comwrites:
On Oct 3, 12:58 pm, Martin Honnen <mahotr...@yahoo.dewrote:
>Sunny wrote:
Does anyone knows, how to all the list of all the elements on the web
page using javascript.

document.getElementsByTagName('*')
should give all elements in the document. Assuming "web page" is an HTML
document and you want the elements in the body then you might only want
to look in the body e.g.
document.body.getElementsByTagName('*')

--

Martin Honnen
http://JavaScript.FAQTs.com/

When I do:
alert(document.getElementsByTagName('*'));
It gives me "Object HTML Collection"
I want to see, all the elements name in my web page.
Well, yeah.

var elements = document.getElementsByTagName("*");
for (var i = 0; i < elements.length; i++) {
alert(elements[i]);
}

Though I would strongly recommend you install firebug, enable it and do:
console.debug(elements);

then check the console.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Oct 3 '08 #4
SAM
Le 10/3/08 7:09 PM, Sunny a écrit :
When I do:
alert(document.getElementsByTagName('*'));
It gives me "Object HTML Collection"
Yes, that is a collection.
I want to see, all the elements name in my web page.
What do you call "name" ?
The name, the id, the tag name ?

var c = [];
var d = document.getElementsByTagName('*');
for(var i=0, n = d.length; i<n; i++) c.push(d[i].tag+Name);
alert(c.join());

but that will not give you the hierarchy
(nor wich ones are imbricated nor in what)
As I am creating some elements dynamically, i want the name of all the
elements present on my webpage.
And I want to do that in Firefox.
Any solution.
use the extension 'FireBug'

--
sm
Oct 3 '08 #5
Sunny <su**********@gmail.comwrites:
When I do:
alert(document.getElementsByTagName('*'));
It gives me "Object HTML Collection"
I want to see, all the elements name in my web page.
As I am creating some elements dynamically, i want the name of all the
elements present on my webpage.
And I want to do that in Firefox.
As you might have gathered from previous replies, you
a) need to do something with the collection
b) it isn’t clear from your description what that would be

If you just want a list of the used element types, you’d want to
avoid duplicates and probably sort the result, e.g.

var list = document.getElementsByTagName('*'),
l = list.length,
result = [],
node;
while (l--) {
node = list[l].nodeName;
if (-1 === result.indexOf(node)) {
result.push(node);
}
}
alert(result.sort());

(Joost’s suggestion applies)
--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011
Oct 3 '08 #6

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

Similar topics

4
by: Stuart Perryman | last post by:
Hi, I have the following code which works just fine in IE6 but not in Firefox. It is an extract of several table rows each with an individual form. It is generated by php. <form...
15
by: Dan | last post by:
Hi. I've got the following line of code which works fine in IE ... line_1_numbers = document.getElementsByTagName ('table').rows (0).cells (0).innerText; But it Firefox, it barks saying: ...
5
by: Martin Chen | last post by:
I have a frame set (as per MS FrontPage 2000). It has a contents and a main frame. The contents frame has a menu bar written with with javascript (in the context of a table). In IE6.1 everything...
1
by: KPS | last post by:
I'm attempting to create a simple treeview-like behavior in JavaScript. The desired behavior happens in IE but I cannot get the same to happen in FireFox. The primary thing I want to accomplish...
4
by: petermichaux | last post by:
Hi, I'm hoping for a reason I'm wrong or an alternate solution... I'd like to be able to dynamically include some javascript files. This is like scriptaculous.js library but their solution is...
7
by: Coder | last post by:
Hi I have the following code in java script, it is not giving proper output in FIREFOX but running fine in IE... can anybody help me out to make this run in FIREFOX . <script...
2
by: Noah Sussman | last post by:
Hello, I am writing a function to reposition an element based on whether one of its edges is outside the visible area of the browser window (the code is below). My client has asked for code...
11
by: shankwheat | last post by:
I have a function which passes text from txtdebt to debtsbox which works fine. However, I want to add code which examines the value of debtsbox and if any of the values the user entered contain the...
9
by: =?Utf-8?B?Sm9obiBCYWlsZXk=?= | last post by:
I have a ASP .Net page that allows moving around items on the page through javascript. This page works fine in IE. In FireFox however, I have found that if the page is using XHTML 1.0...
7
by: mavigozler | last post by:
IE7 does not appear to set an event on contained text inside SPAN elements whose 'onclick', 'onmouseover', and 'onmouseout' events, defying the HTML recommendation. Firefox appears to conform. ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.