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

Load HTML page into another

<html>
<head>
<script type="text/javascript">
function init(){
var html = document.open('Hello.html');
document.getElementById
}
</script>
<body onload ="init();">
<did = 'hi'>
</d>
</body>
</html>
Jun 27 '08 #1
1 1599
Duke wrote:
<html>
<head>
<script type="text/javascript">
* * * * function init(){
* * * * * * * * * * * * var html = document.open('Hello.html');
document.getElementById
Perhaps you meant:

document.getElementById('hi').innerHTML = html;
* * * * }
</script>
<headshould be finished here. W3 requires a doctype declaration and
a page title, too.
<body onload ="init();">
* * * * <did = 'hi'>
* * * * </d>
Perhaps you meant:

<div="hi">
</div>
</body>
</html>
The open-method can't be used here. XMLHttpRequest is meant for that
purpose.

Putting it all together:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Demo</title>
<script type="text/javascript">
var xhr;
function init() {
xhr = null;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
xhr = new ActiveXObject('Microsoft.XMLHTTP');
}

if (xhr != null) {
xhr.onreadystatechange = state_Change;
xhr.open('GET', 'Hello.html', true);
xhr.send(null);
}
else {
alert('Your browser does not support XMLHttpRequest.');
}
}

function state_Change() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
document.getElementById('hi').innerHTML = xhr.responseText;
}
else {
alert('Problem retrieving data:' + xhr.statusText);
}
}
}
</script>
</head>
<body onload="init()">
<div id="hi"></div>
</body>
</html>

But there is an important objection! The content of the <divis now
actually a full HTML-page inside another one. Though browsers might be
"forgiving", it's still invalid and quite dangerous design. The
following variant is more healthy:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Demo</title>
<script type="text/javascript">
function init() {
frames['hi'].location = 'Hello.html';
}
</script>
</head>
<body onload="init()">
<iframe name="hi"></iframe>
</body>
</html>

Hope this helps,

--
Bart
Jun 27 '08 #2

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

Similar topics

3
by: Paul | last post by:
HI! how do we load a page from the menu into an iframe when you are not on the iframe page? I want to be able to load pages (options in my menu ) into a iframe no matter if I am on the iframe...
11
by: Wolfgang Kaml | last post by:
I am not sure if this is more of an expert question, but I am sure that they are out there. I'd like to setup a general application or bin directory on my Win2003.Net Server that will hold some...
7
by: Mad Scientist Jr | last post by:
i have a dropdown control with autopostback=on that when selected, posts back and populates a second dropdown. the 2nd dropdown takes a while to load, giving the user time to start typing in other...
2
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation...
3
by: Mike Dee | last post by:
Hi, I'm having an issue with the status bar in Mozilla and Netscape showing that it is still waiting on the page to load even after it is finished. This problem does NOT occur with IE. In...
8
by: Fish44 | last post by:
Ive got a PHP script, which if it ends correctly, i want load another PHP file or an HTML page automatically, ie without user intervention. The new page shoud replace the current page on the...
1
by: jianxin9 | last post by:
Hi, I have an ajax powered tabs box that has a javascript drop-down search menu in the first tab. When I click on another tab, and go back to the first tab I have to refresh the page to get the...
3
manuelgk
by: manuelgk | last post by:
Hi!, does anybody know how to load a different Web page using a hyperlink?. Now I have my code with some "<a href>" when I click the link, it load the URL of the <a href>. My question is how can I...
11
by: tdmailbox | last post by:
I have a website that I subscribe to that allows me to track tasks. I have an extra computer with a big monitor that i want to always display the task list. the problem is after so many hours I...
1
by: Duke | last post by:
<html> <head> <script type="text/javascript"> function init(){ var html = document.open('Hello.html'); document.getElementById('hi").innerHTML = html; } </script> <body onload ="init();">...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.