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

GetElementByID oddness


Can ayone tell me what the expected behaviour of the
following snippet is:
<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:cml="http://www.xml-cml.org/schema/CML2/Core">
<head />
<body>
<cml:cml id='mol_1'/>
<p>
<script type="text/javascript">
//<![CDATA[
var mol_1 = document.getElementById('mol_1');
var para = document.createElementNS('http://www.w3.org/1999/xhtml','p');
if (mol_1) {
para.appendChild(document.createTextNode("Found mol_1"));
}
else
{
para.appendChild(document.createTextNode("Didn't find mol_1"));
}
document.getElementsByTagName('body')[0].appendChild(para);
//]]>
</script>
</p>
</body>
</html>
I find that, with firefox 1.0.4, and with Deer Park alpha 1,
if the file is named:
bug.html : "Found mol_1"
bug.xhtml: "Didn't find mol_1"
bug.xml : "Didn't find mol_1"

with Konqueror 3.3.2
bug.html : "Didn't find mol_1"
bug.xhtml: "Didn't find mol_1"
bug.xml : "Found mol_1"

And finally - can anyone tell me how I can reliably
get hold of the cml:cml element in javascript?

--
Dr. Toby White
Dept. of Earth Sciences, Downing Street, Cambridge CB2 3EQ. UK
Email: <to***@cam.ac.uk>
Jul 23 '05 #1
1 1677
VK


Toby White wrote:
Can ayone tell me what the expected behaviour of the
following snippet is:
<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:cml="http://www.xml-cml.org/schema/CML2/Core">
<head />
<body>
<cml:cml id='mol_1'/>
<p>
<script type="text/javascript">
//<![CDATA[
var mol_1 = document.getElementById('mol_1');
var para = document.createElementNS('http://www.w3.org/1999/xhtml','p');
if (mol_1) {
para.appendChild(document.createTextNode("Found mol_1"));
}
else
{
para.appendChild(document.createTextNode("Didn't find mol_1"));
}
document.getElementsByTagName('body')[0].appendChild(para);
//]]>
</script>
</p>
</body>
</html>
I find that, with firefox 1.0.4, and with Deer Park alpha 1,
if the file is named:
bug.html : "Found mol_1"
bug.xhtml: "Didn't find mol_1"
bug.xml : "Didn't find mol_1"

with Konqueror 3.3.2
bug.html : "Didn't find mol_1"
bug.xhtml: "Didn't find mol_1"
bug.xml : "Found mol_1"

And finally - can anyone tell me how I can reliably
get hold of the cml:cml element in javascript?

--
Dr. Toby White
Dept. of Earth Sciences, Downing Street, Cambridge CB2 3EQ. UK
Email: <to***@cam.ac.uk>


First you need to decide for yourselve what are you working with: with
HTML or XML/XMLT (what XHTML is I don't know, but must be mean
something to you).

XML by definition is *strictly structured DATA*, only data and nothing
but data. So what is your script doing there (as well as loose HTML
markup) ?

If you decide to use XML/XMLT sets, then the script (as well as any
layout) has to be in XML template. It works great, but currently only
for Firefox 1.0.3 and higher and Explorer 6.x

If you decide to use the conventional HTML, than you can get and parse
any XML data via XMLHttpRequest from the server. That currently gives
you the highest coverage between existing browsers, but *much* less
effective as XML/XMLT.

Also you can include your XML data right into page using XML Island:
<xml>
....
</xml>
The latter again is supported for sure by Firefox 1.0.3 and higher and
Explorer 6.x. I have no info about other pretendents.

So make you mind, depending of your choice there are people here to
help you.

Jul 23 '05 #2

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

Similar topics

1
by: lawrence | last post by:
This PHP function prints out a bunch of Javascript (as you can see). This is all part of the open source weblog software of PDS (www.publicdomainsoftware.org). We had this javascript stuff...
12
by: lawrence | last post by:
The following function correctly makes everything invisible but then fails to turn the one chosen DIV back to visible. I imagine I'm getting the syntax of the variable wrong? I've tried this with...
4
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) {...
3
by: davidkarlsson74 | last post by:
Error: document.getElementById("folderMenu").cells has no properties File: http://www.volkswagen.se/tillbehor/js/foldermenu.js Rad: 49 The function activates different DIV:s, but doesn't seem to...
3
by: John Abel | last post by:
Hi, I'm running Python 2.3.5/2.4.2 on OSX 10.4.2, and am trying to run CGI scripts using the builtin Apache. For ease, I've symlinked my custom modules into the...
4
by: dr1ft3r | last post by:
Hey guys, I'm building a site for a landscaping business down the street and can't seem to get part of the code functioning correctly. The code fails on line 68 where I make a reference to an...
13
by: RommelTJ | last post by:
Hi, My website (http://www.justiceinmexico.org/indextest.php) looks good in Firefox, but horrible in IE, and I think it's because of an error in the javascript of a free web ticker I got off the...
5
by: jhappeal | last post by:
I do not know Javascript that well so I might be going about this the wrong way. Any help would be appreciated. This function attempts to hide the options inside of the optgroup tag of the second...
1
by: cedarmillxing215 | last post by:
The oddness is on the last line of code. This is stripped down as far as I could figure, and I provide several similar examples that work as expected. I have no idea whether this is a compiler...
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: 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
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.