Load HTML page into another HTML page using Javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Duke

    Load HTML page into another HTML page using Javascript

    <html>
    <head>
    <script type="text/javascript">
    function init(){
    var html = document.open(' Hello.html');
    document.getEle mentById('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
  • Tom de Neef

    #2
    Re: Load HTML page into another HTML page using Javascript

    "Duke" <p.sathish.cs@g mail.com>
    <html>
    <head>
    <script type="text/javascript">
    function init(){
    var html = document.open(' Hello.html');
    document.getEle mentById('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.getEle mentById('hi") ->
    document.getEle mentById('hi')
    Maybe <did = 'hi'should be'<d id = 'hi'>.
    And what sort of element is <danyway ? Try <pinstead.
    Rather than loading a html file into an element, would it be a better idea
    to load the body part?
    document.getEle mentById('hi'). innerHTML = html.body.inner HTML;
    Testing is easier when you use onclick instead of onload. In FF+Firebug you
    should be able then to follow execution.

    Tom


    Comment

    Working...