Re: Dynamic loading of javascript files into web pages
- From: Conrad Lender <crlender@xxxxxxxxx>
- Date: Mon, 29 Jun 2009 22:32:23 +0200
On 29/06/09 21:32, David Mark wrote:
On Jun 29, 1:18 pm, Conrad Lender <crlen...@xxxxxxxxx> wrote:
What I have been using is execScript(), if available, or else
window.eval, if available. I'm not happy with this solution, because
both are nonstandard, and not guaranteed to work (IIRC, window.eval is
even guaranteed *not* to work in ES5 strict mode). I wouldn't be
surprised if there were reasonably current UAs which support neither.
Neither of those are acceptable.
Yes, I just said that.
There's a lot about this topic on the web, and in the group archives.
Has there ever been a consensus in this group about the best/safest way
to evaluate code in global context?
As have been mentioned in this thread, search the archive for "dynamic
script injection" (and/or "Webb.")
The problem is that there has been so much discussion about it that it
makes the relevant bits hard to find. If this has been discussed so
much, and is frequently asked, it should probably go in the FAQ, which
would save people from sifting through thousands of posts containing
half-solutions and esoteric cases every time.
Is it really too much to ask which is the "recommended" approach? Is it
creating a script element, setting its .type, adding the code as its
..text, and appending it to the body? Which problems can be expected with
this approach? Is window.setTimeout(code, 0) equivalent, as long as
setTimeout is available, and order of execution doesn't matter? I don't
mind doing research, but I do mind the "I know, but I won't tell" attitude.
- Conrad
.
- Follow-Ups:
- Re: Dynamic loading of javascript files into web pages
- From: Jorge
- Re: Dynamic loading of javascript files into web pages
- From: David Mark
- Re: Dynamic loading of javascript files into web pages
- References:
- Dynamic loading of javascript files into web pages
- From: neilc
- Re: Dynamic loading of javascript files into web pages
- From: Peter Michaux
- Re: Dynamic loading of javascript files into web pages
- From: neilc
- Re: Dynamic loading of javascript files into web pages
- From: Jorge
- Re: Dynamic loading of javascript files into web pages
- From: Garrett Smith
- Re: Dynamic loading of javascript files into web pages
- From: Conrad Lender
- Re: Dynamic loading of javascript files into web pages
- From: Thomas 'PointedEars' Lahn
- Re: Dynamic loading of javascript files into web pages
- From: Conrad Lender
- Re: Dynamic loading of javascript files into web pages
- From: David Mark
- Dynamic loading of javascript files into web pages
- Prev by Date: Re: Poll: How many people would actually hire Thomas Pointed ears?
- Next by Date: Can call/apply be used to invoke constructor?
- Previous by thread: Re: Dynamic loading of javascript files into web pages
- Next by thread: Re: Dynamic loading of javascript files into web pages
- Index(es):
Relevant Pages
|
Loading