[SOLVED] Writing </script> from JavaScript = problem

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

[SOLVED] Writing </script> from JavaScript = problem

Post 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 !
Last edited by Calimero on Tue Nov 16, 2004 2:06 pm, edited 1 time in total.
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Why not use PHP and echo/print the javascript to the page...
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

...

Post by Calimero »

Well,

the idea was to use JS to create JS,

it was going nicely, until I got to this "little" problem

...
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post 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.
User avatar
AnarKy
Forum Contributor
Posts: 119
Joined: Tue Nov 02, 2004 1:49 am
Location: South Africa

Js to make Js

Post 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 8)
User avatar
AnarKy
Forum Contributor
Posts: 119
Joined: Tue Nov 02, 2004 1:49 am
Location: South Africa

Tell us.

Post by AnarKy »

:idea: Perhaps tell us more about what you are trying to do,
then perhaps the advice may get a little better.
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post 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.
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

...

Post by Calimero »

Ok, from this last reply.

The code is ok, but what about statistics, and other uses - please do elaborate.

Thanks !
User avatar
potsed
Forum Commoner
Posts: 50
Joined: Sat Oct 09, 2004 12:00 pm
Location: - South Africa

Post by potsed »

have u tried this idea...
viewtopic.php?t=26674
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

...

Post 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
Post Reply