Forum Moderators: open
<script type="text/javascript">
function callServer(remoteServer) {
var head = document.getElementsByTagName('head').item(0); script = document.createElement('script');
script.src = remoteServer;
script.type = 'text/javascript';
script.defer = false;
script.id = 'lastLoadedCmds';
void(head.appendChild(script));
}
</script>
and the following html code:
<form>
<input type="button" value="Call server" onclick="callServer('test.js');">
</form> to dynamically load and execute external javascript file called "test.js". Inside "test.js" we are just saying:
alert('Inside test.js!'); This code works great in IE 6.0 and Firebird 0.7 (after clicking on "Call Server" button, i can see an alert message "Inside test.js!") but doesn't work at all in Opera 7.23. It seems that Opera creates a new 'script' element properly, but then it doesn't either load it or execute it upon loading.
I've tried to use some other tricks to handle the issue, like using document.write to write the <script src=""></script> tags, but this also doesn't work.
I want to underline that this whole problem appears only when the script element is being generated and loaded when the main document has been already loaded (i.e. we press a button or a link on the page).
Can someone confirm that this is Opera's problem and i should just wait until they fix it? Or am i doing something wrong?
Thanks.