Premetto che di javascript sono autodidatta e non conosco il php per tanto alla seconda pagina mi ero perso.
Io sapevo che javascript poteva fare chiamate al server in due modi asincrone (ajax) o querystring (ricaricamento della pagina) la tua ipotesi come si collocherebbe.
Con queste righe di codice:
Codice PHP:
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 );
}
[url="javascript:attach_file( 'javascript.php' )"]What time is it?[/url]
Praticamente è come facessi una chiamata
al server php travestito da js
nel file javascript.php avrai:
Codice PHP:
//# set appropriate content type - to tell the browser we're returning Javascript
header( 'Content-Type: text/javascript' );