Hi,

I try to change script source dynamically.

When I use the following code, it works fine, and the script is executed

<script type="text/javascript">
document.write('<script src="http://gamestoenjoy.com/site/test.php"');
</script>

However when I use the following code, it doesn't work, the script isn't executed

<script type="text/javascript">
var url = "http://gamestoenjoy.com/site/test.php";
document.write('<script src=url>');
</script>

The only difference between the codes is that in the first code I use constant sting, and in the second code I use variable, in order to make the source dynamic.

Please help me to solve this problem.

Recommended Answers

Do you want to make it dynamic in JavaScript or in PHP? They are different...

Jump to Post

All 4 Replies

Do you want to make it dynamic in JavaScript or in PHP? They are different...

No prob, care to mark solved / vote up?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.