Forum Moderators: open

Message Too Old, No Replies

Opera doesn't reload javascript source file dynamically

         

the_Eych

9:55 pm on Jan 14, 2004 (gmt 0)

10+ Year Member



I am using the following javascript function:

<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.

BlobFisk

11:07 am on Jan 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi the_Eych,

Are you seeing anything at all happen with Opera? Is there an error thrown?

Is it only Opera 7.23, or all Opera versions?

the_Eych

12:53 pm on Jan 16, 2004 (gmt 0)

10+ Year Member



No, no errors at all in the javascript console.

I've only tested with the latest 7.23 version.