appendChild SCRIPT elements

Discussion about official Mozilla Firefox builds
Post Reply
coopster
Posts: 4
Joined: March 21st, 2007, 9:07 am

appendChild SCRIPT elements

Post by coopster »

Note: Starting in Firefox 3.1, you can no longer use this method to append script elements that retrieve their code from anything other than chrome: URLs.
Resource: appendChild


I have been searching trying to find changelogs or discussion on this proposed change in Firefox. Unless I am misunderstanding the note on the Mozilla documentation page for appendChild, we will no longer be able to append a <script> element in the following manner:

Code: Select all

        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = 'test.js';
        document.getElementsByTagName('head')[0].appendChild(script);

Does anybody know where I can read more about this change?
Why it is being incorporated?
And does anybody have any suggested workarounds if this does indeed make it's way into production release?
User avatar
Bluefang
Posts: 7857
Joined: August 10th, 2005, 2:55 pm
Location: Vermont
Contact:

Re: appendChild SCRIPT elements

Post by Bluefang »

This was most likely done for security reasons. Can't find any documentation on it though.
There have always been ghosts in the machine... random segments of code that have grouped together to form unexpected protocols. Unanticipated, these free radicals engender questions of free will, creativity, and even the nature of what we might call the soul...
coopster
Posts: 4
Joined: March 21st, 2007, 9:07 am

Re: appendChild SCRIPT elements

Post by coopster »

I'm guessing you are correct in your assumption regarding security, I leaned that way in my first thoughts too. However, I can use alternative methods to include JavaScript dynamically, including the old document.write fallback so it seems unnecessary. I've been watching and poking around for a week but have still come up empty.

Anybody know where I can find the developers mailing list or changelogs/cvs/svn documents?
User avatar
Bluefang
Posts: 7857
Joined: August 10th, 2005, 2:55 pm
Location: Vermont
Contact:

Re: appendChild SCRIPT elements

Post by Bluefang »

To be honest, I can't find any documentation of this anywhere. And as far as i can tell, Firefox still allows doing this... so I have no idea what to make of it.
There have always been ghosts in the machine... random segments of code that have grouped together to form unexpected protocols. Unanticipated, these free radicals engender questions of free will, creativity, and even the nature of what we might call the soul...
Post Reply