PDA

View Full Version : using <script src="">



VatsaL
11-18-2006, 08:10 PM
Ive come across many sites displaying a page or a part of page with this type of code.

here s an example:


<script src= http://www.gocurrency.com/v2/gocurrcalc_t.php?id=53> </script>

Does it only work for .php, or is it possible to display .htm or through document.write as well?

If so, how?

ItsMeOnly
11-18-2006, 08:44 PM
it's more complicated than this (you will need AJAX implemented), however it has nothing to do with the document.write(), it's just because a PHP script can generate a javascript code and pass it to client (just with appropriate mime type: text/javascript).

Twey
11-18-2006, 08:45 PM
No, what's happening there is that the PHP script is generating Javascript.

VatsaL
11-18-2006, 09:59 PM
No, what's happening there is that the PHP script is generating Javascript.

I tried that with simple .htm files, which didnt work.

Is it possible for for .htm or similar to do the same thing with it or is it just restricted to .php?

Twey
11-18-2006, 10:34 PM
It's not restricted to PHP, but it can't be done with HTML. A valid HTML page is not a valid Javascript file, and vice versa. PHP (and all other server-side scripting languages) are capable of generating any type of file.

VatsaL
11-20-2006, 12:39 AM
ok, so is it possible to display like a paragraph of just simple text through document.write or something similar with javascript?

Twey
11-20-2006, 01:51 AM
It is possible, but it is strongly advised to use server-side scripting for this purpose.