473,320 Members | 2,189 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,320 software developers and data experts.

Problem Accesing all the Elements of the document

Hello Guys
This is the small script I have.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>News Maps</title>
<script type="text/javascript">
function getTags()
{
if(!document.all)
document.all = document.getElementsByTagName("*");

for(var i=0;i<document.all.length;i++)
{
document.write(document.all[i].tagName)
}
}
</script>
</head>

<body>
<div id='feedOutput'>
<br />
</div>

<form name="FeedForm" id="feedForm" method="GET" action="#">
<input type="text" width="1000" name="feedURL"
value="http://localhost/map.xml" size="50" />
<input type="button" value="Syndicate" onclick="getTags();" />
</form>

</body>
</html>

The above function is printing out only the html, head, body tags but
not <div> I was not sure why that happening. Any ideas why ??

Thanks in advance
saki

Oct 23 '05 #1
8 1513
<sr**********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hello Guys
This is the small script I have.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>News Maps</title>
<script type="text/javascript">
function getTags()
{
if(!document.all)
document.all =
document.getElementsByTagName("*");

for(var i=0;i<document.all.length;i++)
{
document.write(document.all[i].tagName)
}
}
</script>
</head>

<body>
<div id='feedOutput'>
<br />
</div>

<form name="FeedForm" id="feedForm" method="GET"
action="#">
<input type="text" width="1000" name="feedURL"
value="http://localhost/map.xml" size="50" />
<input type="button" value="Syndicate"
onclick="getTags();" />
</form>

</body>
</html>

The above function is printing out only the
html, head, body tags but
not <div> I was not sure why that happening. Any
ideas why ??

Thanks in advance
saki


Might this help
http://www.siteexperts.com/tips/cont...s16/page3.asp?
Cheers, Dom
Oct 23 '05 #2
<sr**********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hello Guys
This is the small script I have.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>News Maps</title>
<script type="text/javascript">
function getTags()
{
if(!document.all)
document.all =
document.getElementsByTagName("*");

for(var i=0;i<document.all.length;i++)
{
document.write(document.all[i].tagName)
}
}
</script>
</head>

<body>
<div id='feedOutput'>
<br />
</div>

<form name="FeedForm" id="feedForm" method="GET"
action="#">
<input type="text" width="1000" name="feedURL"
value="http://localhost/map.xml" size="50" />
<input type="button" value="Syndicate"
onclick="getTags();" />
</form>

</body>
</html>

The above function is printing out only the
html, head, body tags but
not <div> I was not sure why that happening. Any
ideas why ??

Thanks in advance
saki


Further: Causes issues in IE, puts FireFox into an
infinite loop, as far as I can tell, but works a
treat in Opera... go figure.
Oct 23 '05 #3


I don't think you can wildcard the argument, so, chances are is not
returning anything but an error on a browser with no document.all object
and ignoring the assigning on the ones that do, as for fetching a file from
the server, check in XMLHttpRequest object instead.
Danny
Oct 23 '05 #4
sr**********@gmail.com writes:
function getTags()
{
if(!document.all)
document.all = document.getElementsByTagName("*");
Remember that document.all is a dynamic collection that changes
when the page changes, whereas the element list returned by gEBTN
is not.
for(var i=0;i<document.all.length;i++)
{
document.write(document.all[i].tagName)
When you do a document.write after a page has loaded, the entire
document is replaced with a new one where the content is written.
If document.all is the dynamic collection, clearing the document
might cause problems.

Instead, you could put the elements into an array and then do
one single document.write (or put it into a text area instead
to completely avoid changing the document structure).

The above function is printing out only the html, head, body tags but
not <div> I was not sure why that happening. Any ideas why ??


Not sure why those excact symptoms occur, but I'm not surprised that
something odd happens :)
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Oct 23 '05 #5
Lasse Reichstein Nielsen wrote:
sr**********@gmail.com writes:
function getTags()
{
if(!document.all)
document.all = document.getElementsByTagName("*");


Remember that document.all is a dynamic collection that
changes when the page changes, whereas the element list
returned by gEBTN is not.

<snip>

This is not necessarily true. The gEBTN method is specified as returning
a - NodeList - and "NodeList objects in the DOM are live." So the
resulting object should be dynamic.

Richard.

Oct 23 '05 #6
Danny wrote:
I don't think you can wildcard the argument,

<snip>

Without a context for your reply the immediate question is "what
argument?". But assuming you are referring to the -
getElementsByTagName - call in the post to which you are responding, you
might consider reading the W3C Core DOM level 2 specification (where -
getElementByTagName - is defined), and save yourself looking more inept
than your failure to produce well-formed newsgroup posts already
suggests.

Richard.

Oct 23 '05 #7
"Richard Cornford" <Ri*****@litotes.demon.co.uk> writes:
This is not necessarily true. The gEBTN method is specified as returning
a - NodeList - and "NodeList objects in the DOM are live." So the
resulting object should be dynamic.


I stand corrected. And it *is* dynamic in the first three browsers I
checked (Opera 8.5, IE 6 and Firefox 1.0.5).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Oct 23 '05 #8
Lasse,
Thanks for the input. I got rid off all the document.writes and
replaced them with alerts, It worked smooth. You seem to be right about
how document.write updates the elementslist. Its working now.

Thanks
saki

Oct 23 '05 #9

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

Similar topics

2
by: Johan Daine | last post by:
Hi everyone, I have a main page (search engine) that pops up a window in wich the user can select a keyword in a select box (up to 4 keywords) The on change attribute of the select tag calls the...
2
by: Kapil Jain | last post by:
Dear All, Please assist me for below code : What i need is -> One "Patient Master" form for online Entry : My AIM -> When somebody want to add new patient a parent form will open than finally...
1
by: DJG79 | last post by:
Hi all, I am using an open source menu that i found and it works great, except for one thing that when the web page is not scrolled to the very top the drop down links will not stay visible. Has...
3
by: andybeh | last post by:
Hi All, Can anyone tell me why the following code does not evaluate correctly on my web page: function calcLabels() { alert('Stage 1'); if (document.labels.elements.frmBundlesPerBox.value...
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
7
by: psybert | last post by:
Hello everyone, Long time lurker, first time poster. I'm a beginner coder, and I've taught myself everything with the help and expertise of users and websites like this one. I normally figure out...
16
by: Mike | last post by:
Hi, I have a form with some controls, and a different class that needs to modify some control properties at run time. Hoy can I reference the from so I have access to its controls and...
1
by: neovantage | last post by:
Hey all, I am using a PHP script which creates headings at run time in a sense at page execution. I am stuck a with a very little problem which i am sure i will have the solution from experts. ...
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.