[nycphp-talk] OT Javascript Question

D C Krook dkrook at
Mon Aug 4 16:04:57 EDT 2003


I don't think it's possible to simply get the contents of the file, but you 
can get the innerText and innerHTML of many elements by tag or id.  That 
process is pretty finicky too as it requires a cutting edge browser and well 
formed HTML.

The easiest way that I can think to approach the problem (depending on 
whether you can use PHP or whether your page content is determined before or 
after page pre-processing) is to dump the results of a PHP readfile into the 
JavaScript variable:

var pageContents = <? addslashes(readfile($_SERVER['PHP_SELF'])) ?>

If all else fails, this guide is pretty handy for JS DOM element reading:

>To all those JS gurus out there (Krook!),
>Is there a way to get the HTML source of a page into a javascipt variable
>(on the same page)?

MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.

More information about the talk mailing list