Load HTML page into another HTML page using Javascript

D

Duke

<html>
<head>
<script type="text/javascript">
function init(){
var html = document.open('Hello.html');
document.getElementById('hi").innerHTML = html;
}
</script>
<body onload ="init();">
<did = 'hi'>
</d>
</body>
</html>

this code is not working Help me load hello.html page into this
index.html page
 
T

Tom de Neef

Duke said:
<html>
<head>
<script type="text/javascript">
function init(){
var html = document.open('Hello.html');
document.getElementById('hi").innerHTML = html;
}
</script>
<body onload ="init();">
<did = 'hi'>
</d>
</body>
</html>

this code is not working Help me load hello.html page into this
index.html page

Something wrong with your quotes: document.getElementById('hi") ->
document.getElementById('hi')
Maybe <did = 'hi'> should be'<d id = 'hi'>.
And what sort of element is <d> anyway ? Try <p> instead.
Rather than loading a html file into an element, would it be a better idea
to load the body part?
document.getElementById('hi').innerHTML = html.body.innerHTML;
Testing is easier when you use onclick instead of onload. In FF+Firebug you
should be able then to follow execution.

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,235
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top