Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] reassign the script src attribute
- From: wdlists at triche-osborne.com (Triche Osborne)
- Subject: [Javascript] reassign the script src attribute
- Date: Wed Aug 17 15:25:43 2005
Mike Dougherty wrote:
> Are there any caveats to reassigning a script tag's source attribute?
>
> Is this possible: (notice the SKU() function is different in each
> source file)
>
> <script id='productscript' src='productA.js' type='text/javascipt'
> ></script>
> <script type='text/javascript'>
> if(productA){ var myobj = new SKU(); }
> else {
> document.getElementById('productscript').src = 'productB.js' ;
> var myobj = new SKU();
> }
> </script>
Hi Mike,
I did some testing, but the problem seems to be that while the source
attribute does change, the file itself doesn't attach. (I put an alert
statement in each of the two script files, but outside of their
functions, so I would know when/if each file loaded.)
I thought of trying the technique used for preloading images, but when
I tried to create a new HTMLScriptElement, the JS console throws an
error that says "object cannot be created in this context." It makes
sense that it would object to trying to create a script from within
another, but I was curious.
Triche
- Follow-Ups:
- [Javascript] reassign the script src attribute
- From: Mike Dougherty
- [Javascript] reassign the script src attribute
- References:
- [Javascript] reassign the script src attribute
- From: Mike Dougherty
- [Javascript] reassign the script src attribute
- Prev by Date: [Javascript] reassign the script src attribute
- Next by Date: [Javascript] reassign the script src attribute
- Previous by thread: [Javascript] reassign the script src attribute
- Next by thread: [Javascript] reassign the script src attribute
- Index(es):