Ciao.
Prova con questo:
(l'esempio è molto
ma è per rendere l'idea)
Pagina htm:
Codice PHP:
<HTML>
<head>
<title>PHP & Javascript - Example</title>
<SCRIPT type="text/javascript">
function attach_file( p_script_url ) {
// create new script element, set its relative URL, and load it
script = document.createElement( 'script' );
script.src = p_script_url;
document.getElementsByTagName( 'head' )[0].appendChild( script );
}
</SCRIPT>
</head>
<body>
[url="javascript:attach_file( 'js.php' )"]Schizza[/url]
<span id="dynamic_span" />
</body>
</HTML>
Pagina js.php:
Codice PHP:
<?php
# set appropriate content type - to tell the browser we're returning Javascript
header( 'Content-Type: text/javascript' );
function js()
{
return 'inner_html';
}
?>
// retrieve span object, and attach additional HTML to it
dynamic_span_obj = document.getElementById( 'dynamic_span' );
dynamic_span_obj.innerHTML += '<?php echo js(); ?>';