473,847 Members | 2,057 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem adding HTML content loaded using document.load()

Hi,

I'm building a tree control that lazily loads branches of the tree
using the document.load() method.

The external XML document that is loaded is generated by a servlet as
XHTML. What I would like to do is to add the new tree branch to the
correct place in the document in the browser window using the innerHTML
property of the parent node.

The relevant code snippet that I've written to do this is:

var target = document.getEle mentById(parent Id);
target.innerHTM L = xmlDoc.document Element.xml;

This doesn't work, furthermore looking at the W3C DOM API it would seem
that the document.xml property is a Microsort proprietary extension
which makes it unsuitable for my application.

Any pointers on where I'm going wrong are much appreciated.

Cheers
Adam

Jul 23 '05 #1
3 2165
ad**@prema.co.n z wrote:
<snip>
var target = document.getEle mentById(parent Id);
target.innerHTM L = xmlDoc.document Element.xml;

This doesn't work, furthermore looking at the W3C DOM API it would seem
that the document.xml property is a Microsort proprietary extension
which makes it unsuitable for my application.


Why not

target.appendCh ild(xmlDoc.docu mentElement.clo neNode(true));

?
Jul 23 '05 #2


Paul R wrote:
ad**@prema.co.n z wrote:
<snip>
var target = document.getEle mentById(parent Id);
target.innerHTM L = xmlDoc.document Element.xml;

This doesn't work, furthermore looking at the W3C DOM API it would seem
that the document.xml property is a Microsort proprietary extension
which makes it unsuitable for my application.

Why not

target.appendCh ild(xmlDoc.docu mentElement.clo neNode(true));


That is certainly the right idea in browsers like Mozilla (and its
derives Netscape 6/7, Firefox) and Opera 7 which have its own DOM
implementation dealing interoperable with both XML and HTML but then you
should do it properly and use

target.appendCh ild(target.owne rDocument.impor tNode(xmlDoc.do cumentElement,
true));

but I think the original poster is dealing with IE/Win which uses MSXML
for XML parsing and XML DOM stuff and unfortuntately there you cannot
simply move nodes from an MSXML XML DOM document to an IE HTML DOM
document, you are left with writing your own importNode method which
tediously creates all nodes/attributes as needed or you can use
innerHTML to have IE parse markup sent. I think Sarissa
(<http://sarissa.sourcef orge.net/doc/>), a library trying to provide a
cross browser API for XML and XSLT stuff, implements importNode for IE
and in its implementation
(<http://sarissa.sourcef orge.net/doc/overview-summary-sarissa.js.html >)
mentions that innerHTML has proven to be much faster for than using DOM
createXXX methods.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3
Hi Paul, Martin

Thanks for clarifying how this works. I'm writing a cross-browser
script so I'm going to go with Sarissa, it seems to do a nice job of
hiding the browser-specific APIs.

Regards,
Adam

Jul 23 '05 #4

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

Similar topics

5
5071
by: Paul | last post by:
The problem I am having involves the sequence of events between frames in an html page. The Pages: Page A has an imbedded IFrame which displays Page B. Page A has a radio button which on the onClick event calls a function which
7
1791
by: Merlin | last post by:
Hi there, I have a problem with opening new windows with JS. If the webpage did not complete loading due to any reason a click on a link which is supposed to open a small new other window loads instead the home page. If the page completes loading the link is working perfect. Here is the code: <a href="#" onclick="open_center('/subapp_profiles/member-information.php?id=00000028',475,500);return
7
3651
by: majid | last post by:
I want write a program with c# to pars a html file how ccan i do this with system.mshtml? or there is other way to do it p;ease help me?
1
2333
by: Kris van der Mast | last post by:
Hi, been a while since I posted a question myself instead of trying to help others out. I'm refactoring an existing web app that uses dynamic loading of user controls and a lot of response.redirects to the same page. Because I hate the overhead by doing this I'm searching for a cleaner option. But I'm having troubles (off course or I wouldn't be posting this).
3
2604
by: Andy Baxter | last post by:
I have an image scrolling in a viewport for a panoramic image viewer. The viewport can be resized to several set resolutions so people can adjust the size according to their bandwidth. There are hotspots on the image which have been defined using an image map. This map is generated in javascript using the following code (in the object 'tour.'): makeImageMap: function() { // creates an HTML nodeset which is an imagemap for the current...
9
2605
by: tshad | last post by:
This was posted before but the message got messed up (all NLs were stripped out for some reason). I have 2 labels that hold the name of different images on my .aspx page. <asp:Label ID="Logo" runat="server"/> <asp:Label ID="CompanyPicture" runat="server"/> I have 2 links that open the windows to preview these images. The previewed images are done on separate html pages that do nothing but display the
2
3160
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 then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ... Pls inform me as early as possible .. I am waiting for ur quick replay ...Here i attached the source code .... <!DOCTYPE...
1
3198
by: wenijah | last post by:
Hi everyone! First thank you for reading this post and yes, you probably already see that kind of topic title somewhere but the problem I've got today might be different than the 100 topics I've seen so far that did not resolve my problem... Environment and problem: I have a page A with Ajax.js and a <div id="ajx">Content</div> that changes when clicking on a link. Another page, page B, gets loaded into page A and (tries) to load a...
0
9892
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9734
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,...
1
10718
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
10347
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...
0
9493
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7888
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...
1
4540
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
2
4130
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3168
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.