Load HTML page into another HTML page using Javascript

Discussion in 'Javascript' started by Duke, Apr 18, 2008.

  1. Duke

    Duke Guest

    <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
    Duke, Apr 18, 2008
    #1
    1. Advertising

  2. Duke

    Tom de Neef Guest

    "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


    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
    Tom de Neef, Apr 18, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    12,127
    Beauregard T. Shagnasty
    Jan 10, 2006
  2. David Virgil Hobbs
    Replies:
    2
    Views:
    17,241
  3. Matcon
    Replies:
    3
    Views:
    21,538
    Matcon
    May 28, 2008
  4. ste-m
    Replies:
    1
    Views:
    301
  5. Duke

    Load HTML page into another

    Duke, Apr 18, 2008, in forum: Javascript
    Replies:
    1
    Views:
    89
    Bart Van der Donck
    Apr 20, 2008
Loading...

Share This Page