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

Create DOM object holding an external page

Is there a way to create a DOM document object to hold the contents of
an external html?

I have two pages:
content.html contains some content.
index.html would like to access the contents of a particular <div> with
an id of "important" within content.html.

how would I do this? I know I can hack around and load the
content.html in an iframe embedded in index.html. Then, I can make the
iframe not visible. But, If theres a better way to do this (an easier
way), I'd much rather take that approach.

Vince

Apr 28 '06 #1
2 1863
vhg119 wrote:
Is there a way to create a DOM document object to hold the contents of
an external html?

I have two pages:
content.html contains some content.
index.html would like to access the contents of a particular <div> with
an id of "important" within content.html.

how would I do this? I know I can hack around and load the
content.html in an iframe embedded in index.html. Then, I can make the
iframe not visible. But, If theres a better way to do this (an easier
way), I'd much rather take that approach.

Vince


If content.html is valid xhtml(xml), then you could parse the document
like an xml file.

http://www.google.com/search?q=javascript+parse+xml

The other alternitive is to have a server page parse the document and
return the content you want. You could do this dynamicly using the
XmlHttpRequest object, or even simpler using
var s = document.createElement("script");
s.src = "http://www.u.com/getpage.php?u=<url>&d=<id of div>";
the getpage file could open the resource in $u and search for a div
with an id of $d

- JS

Apr 28 '06 #2


vhg119 wrote:
how would I do this? I know I can hack around and load the
content.html in an iframe embedded in index.html. Then, I can make the
iframe not visible. But, If theres a better way to do this (an easier
way), I'd much rather take that approach.


Use the iframe, there are no pure in memory text/html DOM
implementations currently in browsers that would allow loading from a URL.
Iframes on the other hand are quite well supported.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 29 '06 #3

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

Similar topics

0
by: Phil | last post by:
I realize this is the php group, but I have a question that recurses back to my php install. My objective is a pure 64 bit shared object installation of php 5.0 on UltraSparc Solaris 9 compiled...
8
by: Steve Neill | last post by:
Can anyone suggest how to create an arbitrary object at runtime WITHOUT using the deprecated eval() function. The eval() method works ok (see below), but is not ideal. function Client() { }...
12
by: marcadonis | last post by:
Hi! Does anybody know of a way that I can keep a reference to an object that I can then reuse? I tried various approaches using navigator, but these all fail in an iframe due to premission...
8
by: MattB | last post by:
Hello I am starting a new thread in a button click event. This thread calls an method which sends emails, I don't want the page to wait for the emails to finish going out as it slows the user...
4
by: blackhawk | last post by:
I need to build a web page that has to potentially display a large amount of data in two grids on the same page. The HTML file with all of the formatting is about 7MB in size. This is too large...
15
by: joun | last post by:
Hi all, i want to create in my asp.net application a custom server variable, so i can retrieve later in other pages (even asp or perl) with request.servervariables("HTTP_mycustomvariable") ...
1
by: Dave | last post by:
I have multiple forms that will create an object. Basically a energy efficiency measure object. The measure object will have a couple of required properties set but after that it can have 10-20...
2
by: Veloz | last post by:
Hiya My question is whether or not you should associated related objects in your software using a scheme of id's and lookups, or wether objects should actually hold actual object references to...
11
by: Mark B | last post by:
I want to display a pre-designed graphical 'performance badge' on certain webpages (round, about 2cm diameter) next to a salesperson's details. I have a function,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
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
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.