Load HTML page into another HTML page using Javascript - Javascript

This is a discussion on Load HTML page into another HTML page using Javascript - Javascript ; <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...

+ Reply to Thread
Results 1 to 3 of 3

Load HTML page into another HTML page using Javascript

  1. Default Load HTML page into another HTML page using Javascript

    <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

  2. Default Re: Load HTML page into another HTML page using Javascript

    "Duke" <p.sathish.cs@gmail.com>
    > <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



  3. Default Re: Load HTML page into another HTML page using Javascript

    document.load loads the newer html in place of your existing html.
    if "hi" refers to an element in your earlier html, getElementById will return NULL.

+ Reply to Thread