Page 1 of 1
[SOLVED] Writing </script> from JavaScript = problem
Posted: Wed Nov 10, 2004 8:25 am
by Calimero
Ok,
Here's the problem,
I need my JS to write on the page some text - some variable content,
and before it the TAG <script>
and behind it the TAG </script>
And to do it without stoping the current script.
All of you who had this problem, please reply.
Thanks Ahead !
Posted: Wed Nov 10, 2004 8:31 am
by neophyte
Why not use PHP and echo/print the javascript to the page...
...
Posted: Wed Nov 10, 2004 8:41 am
by Calimero
Well,
the idea was to use JS to create JS,
it was going nicely, until I got to this "little" problem
...
Posted: Wed Nov 10, 2004 9:46 am
by neophyte
You can't use JS to make JS as far as I know. If you figure out how to do it be sure to post it.
Js to make Js
Posted: Wed Nov 10, 2004 10:18 am
by AnarKy
I agree,
Using Js to make Js is pointless,
if you do this then it is no different from just writing js functions.
Rather use php to create the js script on the server,
which will execute in the client browser upon some event.
Make your life easy

Tell us.
Posted: Wed Nov 10, 2004 10:21 am
by AnarKy

Perhaps tell us more about what you are trying to do,
then perhaps the advice may get a little better.
Posted: Thu Nov 11, 2004 2:44 pm
by rehfeld
document.write('<scr'+ipt src="script.js">'+'or some code'+'</scr'+'ipt>')
this is espescially usefull for statistics gathering
you can do a few things you otherwise couldnt.
...
Posted: Thu Nov 11, 2004 4:08 pm
by Calimero
Ok, from this last reply.
The code is ok, but what about statistics, and other uses - please do elaborate.
Thanks !
Posted: Mon Nov 15, 2004 2:02 pm
by potsed
have u tried this idea...
viewtopic.php?t=26674
...
Posted: Tue Nov 16, 2004 2:06 pm
by Calimero
Found the solution !!!
Code: Select all
<?php
<script language="javascript">
var write_this = "<script" + "> .... anything - even complete JavaScript script </" + "script>";
// used only with document.write(), couldn't make it work with getElementById.
document.write(write_this);
</script>
?>
To check for your self insert a function inside, and test it.
text for myself (I knew this was possible

)
Hope this comes usefull sometimes.
See ya