TAS
04-03-2003, 06:01 PM
Folks,
Thanks for taking the time to read this, because if you're good at JavaScript, I can really use your help.
Background:
Within a browser that supports scripts, the following line should fetch a javascript program, run it, and even allow it to affect the content of the current page (document.write(), etc.):
<script language=JavaScript src="http://x.x.x.x/my_prog.js"></script>
Question:
Is it possible to let a good ol' C/C++ program (or any other language, for that matter), feed back the JavaScript program on stdout? Consider the following:
<script language=JavaScript src="http://x.x.x.x/cgi-bin/feed_js_code_to_browser.cgi"></script>
What I know so far:
The httpd on my server will actually respond to this by running the requested program. Anything written to stdout actually makes it back to the browser, but it is not interpreted as a javascript program. When just sending Javascript lines of code, I get errors. As a test, I sent back html, and the browser removes the current content and replaces it with what I sent.
I think the hurdle involves properly formatting the JavaScript lines of code fed back to the browser. Quoting the O'Reilly koala book for HTML, in regards to the src= attribute:
"The value of the src attribute is the URL of the file containing the JavaScript program. The stored file should have a MIME type of application/x-javascript, but it will be handled automatically by a properly configured server if the filename suffix is .js."
This leads me to believe that this is possible, if I can just properly format the text of the JavaScript code lines sent to the browser.
Thanks in advance for any hints or leads you can give me.
-TAS
Thanks for taking the time to read this, because if you're good at JavaScript, I can really use your help.
Background:
Within a browser that supports scripts, the following line should fetch a javascript program, run it, and even allow it to affect the content of the current page (document.write(), etc.):
<script language=JavaScript src="http://x.x.x.x/my_prog.js"></script>
Question:
Is it possible to let a good ol' C/C++ program (or any other language, for that matter), feed back the JavaScript program on stdout? Consider the following:
<script language=JavaScript src="http://x.x.x.x/cgi-bin/feed_js_code_to_browser.cgi"></script>
What I know so far:
The httpd on my server will actually respond to this by running the requested program. Anything written to stdout actually makes it back to the browser, but it is not interpreted as a javascript program. When just sending Javascript lines of code, I get errors. As a test, I sent back html, and the browser removes the current content and replaces it with what I sent.
I think the hurdle involves properly formatting the JavaScript lines of code fed back to the browser. Quoting the O'Reilly koala book for HTML, in regards to the src= attribute:
"The value of the src attribute is the URL of the file containing the JavaScript program. The stored file should have a MIME type of application/x-javascript, but it will be handled automatically by a properly configured server if the filename suffix is .js."
This leads me to believe that this is possible, if I can just properly format the text of the JavaScript code lines sent to the browser.
Thanks in advance for any hints or leads you can give me.
-TAS