[nycphp-talk] OT Javascript Question

Andrew Yochum andrew at
Mon Aug 4 16:21:36 EDT 2003

On Mon, Aug 04, 2003 at 04:04:57PM -0400, D C Krook wrote:
> Kushner,
> 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'])) ?>

Beware of the recursion problem this introduces... you could easily bring a
server to its knees if that isn't corrected.

> 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)?
> >
> >Thanks,
> >Daniel

Andrew Yochum
Digital Pulp, Inc.
andrew at

More information about the talk mailing list