473,749 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Load xml in Javascript doesnt work in firefox

Hi,

The following code works fine in IE7 but FF returns with an error:

Access denied to achieve the property Element.firstCh ild. In this
line:
nodes = xmlDoc.document Element.childNo des;

My code:

function CheckNick()
{
nick = document.getEle mentById("nick" );
nickName = nick.value;

if (window.ActiveX Object)
{
xmlDoc = new ActiveXObject(" Microsoft.XMLDO M");
xmlDoc.onreadys tatechange = function () {
if (xmlDoc.readySt ate == 4) handleXML()
};
xmlDoc.load("is NickAvailable.p hp?nick="+nickN ame+"&IEHACK="+ (new
Date()).getTime ());
}
else if (document.imple mentation &&
document.implem entation.create Document)
{
xmlDoc = document.implem entation.create Document("", "", null);
xmlDoc.onload = handleXML;
xmlDoc.load("is NickAvailable.p hp?nick="+nickN ame+"&IEHACK="+ (new
Date()).getTime ());
}

else
{
alert('Your browser can\'t handle this script');
return;
}

}
function handleXML()
{
nodes = xmlDoc.document Element.childNo des;
alert(nodes.ite m(0).text);
//
alert(xmlDoc.ge tElementsByTagN ame('nick').chi ldNodes.firstCh ild.nodeValue);
}
Regards

Hush
Aug 7 '08 #1
20 2877
Hush wrote:
The following code works fine in IE7 but FF returns with an error:

Access denied to achieve the property Element.firstCh ild. In this
line:
nodes = xmlDoc.document Element.childNo des;
It is not likely that you get an error on 'firstChild' in an expression
that does not contain that name.

function handleXML()
{
nodes = xmlDoc.document Element.childNo des;
alert(nodes.ite m(0).text);
//
alert(xmlDoc.ge tElementsByTagN ame('nick').chi ldNodes.firstCh ild.nodeValue);
That expression does not make sense, getElementsByTa gName gives a
collection which you can index, and childNodes gives a collection which
you can index too.
I think you should show us the XML you load and describe the elements
you want to read out, then we can help coding the access to those elements.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 7 '08 #2
On 7 Aug., 14:41, Martin Honnen <mahotr...@yaho o.dewrote:
Hush wrote:
The following code works fine in IE7 but FF returns with an error:
Access denied to achieve the property Element.firstCh ild. In this
line:
*nodes = xmlDoc.document Element.childNo des;

It is not likely that you get an error on 'firstChild' in an expression
that does not contain that name.
Sorry, I typed it wrong. Its of course Access denied to achieve the
property Element.childNo des, and not firstNode.
That expression does not make sense, getElementsByTa gName gives a
collection which you can index, and childNodes gives a collection which
you can index too.
I think you should show us the XML you load and describe the elements
you want to read out, then we can help coding the access to those elements.
Ok. Actually I only want to extract 1 number (1 or 0) so I only need 1
value from the XML. My XML is as follows:
<?xml version="1.0" encoding="iso-8859-1"?>
<nick>
<isa>0</isa>
</nick>

I'm trying to get the value of the element <isa>

Hush

Aug 7 '08 #3
Hush wrote:
Ok. Actually I only want to extract 1 number (1 or 0) so I only need 1
value from the XML. My XML is as follows:
<?xml version="1.0" encoding="iso-8859-1"?>
<nick>
<isa>0</isa>
</nick>

I'm trying to get the value of the element <isa>
var isaElements = xmlDoc.getEleme ntsByTagName('i sa');
if (iseElements.le ngth 0)
{
var isa = isaElements[0];
var n = isa.firstChild. nodeValue;
}
else
{
// handle case that 'isa' element was not found
}

That assumes that the 'isa' element always has some text in it.


--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 7 '08 #4
>
* *var isaElements = xmlDoc.getEleme ntsByTagName('i sa');
* *if (iseElements.le ngth 0)
* *{
* * *var isa = isaElements[0];
* * *var n = isa.firstChild. nodeValue;
* *}
* *else
* *{
* * *// handle case that 'isa' element was not found
* *}
I'm stil getting the error for firstChild in this line:
var n = isa.firstChild. nodeValue;

I tested in IE. And it worked nicely...
Aug 7 '08 #5
Hush wrote:
I'm stil getting the error for firstChild in this line:
var n = isa.firstChild. nodeValue;
Can you post the exact error message? Your first post said "access
denied" which sounds more like a security exception. I am not sure why
you would get that, if you tried to load the XML from a different origin
then I would expect the load call to already throw an exception.
If you have a URL we can visit then post that too.

Does that problem occur with Firefox 3? Have you checked whether it also
occurs with Firefox 2?

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 7 '08 #6
On 7 Aug., 18:14, Martin Honnen <mahotr...@yaho o.dewrote:
Hush wrote:
*I'm stil getting the error for firstChild in this line:
var n = isa.firstChild. nodeValue;

Can you post the exact error message? Your first post said "access
denied" which sounds more like a security exception. I am not sure why
you would get that, if you tried to load the XML from a different origin
then I would expect the load call to already throw an exception.
If you have a URL we can visit then post that too.

Does that problem occur with Firefox 3? Have you checked whether it also
occurs with Firefox 2?

--

* * * * Martin Honnen
* * * *http://JavaScript.FAQTs.com/
I translated the error from a danish version of firebug. I'm using
FF3, but when I come to think of it I had a similar error a while ago
with the same error. This was in an unchanged code, but after the
upgrade to FF3, so this could definately be the cause. I havent tested
in FF2. ( I will try that now)

URL:
http://www.sporturn.com/new/popuppages/new_profile.php
Aug 7 '08 #7
Does that problem occur with Firefox 3? Have you checked whether it also
occurs with Firefox 2?
It works in FF2. So the problem is in FF3 :|

Is there a fix??

Aug 7 '08 #8
Hush wrote:
>>Does that problem occur with Firefox 3? Have you checked whether it also
occurs with Firefox 2?

It works in FF2. So the problem is in FF3 :|
Oddly enough I have just tested with Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1 and entered some
characters into the "nick" field and I don't get any error in the error
console, instead each time an alert dialog with '1' is displayed.
Is there a fix??
I am still not sure why you get that error and I can't reproduce it.
As a workaround you might want to try to load the XML with
XMLHttpRequest instead of xmlDoc.load(), perhaps that avoids the problem.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 7 '08 #9
Hush wrote:
>>Does that problem occur with Firefox 3? Have you checked whether it also
occurs with Firefox 2?

It works in FF2. So the problem is in FF3 :|
True, but that does not necessarily mean that the problem *is* Fx 3.
For example, Firebug for Fx 3 is still beta.
Is there a fix??
For a start, you could try not to mix standards compliant and proprietary
features, which would be a good idea in any case.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Aug 7 '08 #10

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

Similar topics

4
3637
by: nec | last post by:
Hi, I'm having trouble calling a function thats located in a iFrame from the parent. Shortly, i can't figure out the location in DOM. In IE it works fine with a simple line of window.contens.alerter('wassa?'), but it doesnt, of course work in Firefox (0.8). I've tried document.getElementById('contens').alerter('wassa?') and
1
1752
by: Rose Girl | last post by:
I have a web application that uses xsl and javascript which runs smoothly on IE. Recently i decided to try it on FireFox 1.0 . But the same application gives javascript errors as displayed in the console. What i found out is that FireFox doesnt recognize Javascript functions from a xsl page. Its ok from a html page. I have given a code of a xsl page. Can someone point what possibly could be the problem. <?xml version="1.0"...
4
2667
by: simon.cigoj | last post by:
I have an javascript made menu and some forms with the dropdown element. When the menu opens and scrolls down the drop down is displeyed over the menu and obscures the menu choices. I have this problem only in IE, in firefox it works ok. Is there a solution to this problem? I tried to hide the drop down when the menu opens but sometimes the menu covers only a small part of the drop down, but enough to obscure the menu choice. I would...
4
4454
by: Paul Fi | last post by:
im trying to change the width of an object dynamically, this i s the object inside an html form input name="btnEmpty" id = "btnempty" type="button" class="" value=""
3
7275
by: 9DeT | last post by:
The javascript works perfect on IE, but on firefox it doesnt. I've pasted both frames source, as well as the page source ( the right frame source.txt was zipped to fit the maximum size allowed) the combobox on the left frame doesnt work ( should extract the items from my db ) when i pick an item on the left frame and go to "add" on the right frame i doesnt work, same when i go to the top frame to hit "validate" In short THERE IS A...
1
1902
by: Rabel | last post by:
Hi I am updating some pages from a website that is a few years old and I didnt work on the site then, but the javascript works in ie but not in firefox. The scripting is function yyLayerScroll(daTarget, delay, ex, ey, dx, dy, sx, sy, daT, daLoop, daFirst ) { var yyX; var yyY; var target = MM_findObj(daTarget); if(!target.oritop){ target.oritop = (document.layers)?target.top:target.style.top; target.orileft =...
3
7400
by: robudo | last post by:
Hello, I need some help to solve the following problem. I wrote some html/javascript code to read data from an XML file: XML file: <places> <place year="2000" name="Amsterdam" /> <place year="2000" name="Amstelveen" /> </places> html/javascript code:
3
1541
by: neoseeker191 | last post by:
It works fine in Firefox 2+ but in IE7 the alert window doesnt appear and the script doesnt work. Maybe I'm missing something Heres the form the script is tied to: <form id="Quiz" name="Quiz" method="get" > <table width="405" table="table" height="24" border="0" align="center"> <!--DWLayoutTable-->
2
6968
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html and i am implementing it in my website....
0
8833
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9568
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9335
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6801
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4709
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4881
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3320
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2218
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.