Posted by joksnet on 01/11/06 21:36
Some example of dynamically create a script tag is:
<script type="text/javascript">
head = document.getElementsByTagName("head")[0];
script = 0;
function create_script(file){
if(script){
head.removeChild(head.lastChild);
}
s = document.createElement('SCRIPT');
s.src=file;
s.id='scriptCat';
head.appendChild(s);
script = 1;
}
create_script('foo.php?msg=something');
</script>
-----------------
--- foo.php ---
-----------------
<?
echo "alert(" . $_GET['msg'] . ");";
?>
[Back to original message]
|