Page 1 of 1

Newbie Question

Posted: Thu Feb 19, 2004 10:51 pm
by jp_css
I was wondering if there could be a way, PHP preferably, to have a javascript execute and to obtain the html from that rendering and placing that html onto a page. I have tried to read from a file, but of course it has been giving me the exact code(javascript) of the page. Any ideas, suggestions, etc. would be helpful.

Posted: Thu Feb 19, 2004 11:11 pm
by Illusionist
could you be more specific? you confused the he1l outta me!

Posted: Thu Feb 19, 2004 11:18 pm
by jp_css
Ok. Here is a sequence of events that I would think could work, it is just that I don't know how to do it. Maybe somebody could help:

1. Someone visits a webpage
2. This site has a javascript that generates a table
3. The javascripts executes possibly elsewhere in a php file
4. The html generated by the javascript is passed from elsewhere and included into the page that the user is looking at.

Thus, in the source we have the html version of the code.

Posted: Thu Feb 19, 2004 11:54 pm
by Illusionist
ok, so like put your javascript in a PHP page, and then use the include() and include taht php page where ever you need...

Code: Select all

include("javascripts.php");

Posted: Thu Feb 19, 2004 11:59 pm
by jp_css
Well that is what I am saying doesn't work. It's pretty easy to include the javascript, but if you look in the source it is still the javascript. I want the javascript to be render first, then place that actual html into the page.

Posted: Fri Feb 20, 2004 12:24 am
by jp_css
Anyone have any clue?

Posted: Fri Feb 20, 2004 1:43 am
by Ixplodestuff8
Javascript is a client-side language, you can't hide it normaly. I did a google search for "server side javascript" and got some results, look into it.

Posted: Fri Feb 20, 2004 10:07 pm
by jp_css
Would it be possible at all to load the javascript in a seperate file so that when someone loads a page, the javascript is processed, then to copy the html from that process into the real page?

Posted: Fri Feb 20, 2004 10:09 pm
by Illusionist
you could use

<script src="javascript_page.js" type="text/javascript"></script>

and fi you put that at the top of your page, that'll be the only thing visible int he view source...

Posted: Fri Feb 20, 2004 10:18 pm
by d3ad1ysp0rk
only solution is to have 2 pages

one does all your stuff, then transfers them (window.location) to page2.php?var1=value&var2=value, etc, then those variables would become accesible in PHP