Reading current HTML page javascript problem

Discussion in 'HTML & Website Design' started by rickvb, Nov 15, 2008.

  1. #1
    Dear reader,

    I'm trying to write a script that reads the entire HTML page through javascript.

    The layout is like this. I can't put the javascript at the end in this case. So that doesn't present a solution for me.

    -- index.html ---------------------------------------------------

    <head></head>
    <body>
    <script type="text/javscript">
    document.write(unescape("%3Cscript type='text/javascript' src='s.js'%3E%3C/script%3E"));
    </script>
    blah blah blah blah <br />
    blah blah blah blah <br />
    </body>

    - s.js -----------------------------------------------------------

    content=document.getElementsByTagName('body')[0].innerHTML;
    alert(content);

    -----------------------------------------------------------------

    Unfortunatly this script doesn't read the blah blah blah blah part and quits reading after </script>.
    I have tried adding an `window.onload` event listener prior to the javascript code execution but it doesn't fix my problem.
    I also tried adding defer to the script tag but no succes there either.

    I hope someone can help me with this.

    Kind regards,

    Rick
     
    rickvb, Nov 15, 2008 IP