Re: Dynamic loading of javascript files into web pages



On Jun 28, 3:37 am, Jorge <jo...@xxxxxxxxxxxxxxxxx> wrote:
On Jun 28, 7:20 am, Garrett Smith <dhtmlkitc...@xxxxxxxxx> wrote:



Jorge wrote:
On Jun 27, 7:23 pm, Garrett Smith <dhtmlkitc...@xxxxxxxxx> wrote:
(...)
Steve says the technique is "safer". It is less safe because of the use
of eval. That point should have been clear.(...)

BTW, could you explain to me why/how is it any unsafer eval
(script.text) than a <script> tag ?

The eval function uses the calling context's [[Scope]], Variable object,
and |this| value.

When eval is called, and the code inside eval is parsed, assignment to
identifiers inside that eval'd code resolve to the calling context's
variable object when it is invoked.

Using a SCRIPT tag, that behavior does not happen.

Thanks, but AFAICS, an eval('code') at the top level is ===
<script>'code'</script> :

- 'this' === window,

Bad assumption, but irrelevant here.

- [[scope]] === global context, and

Not exactly.

And are you planning to run this XHR/eval combo in the global
context? I would expect it to reside in a function.

- no Variable 'object'.

See above.
.



Relevant Pages

  • Re: Dynamic loading of javascript files into web pages
    ... It is less safe because of the use ... than a <script> tag? ... variable object when it is invoked. ...
    (comp.lang.javascript)
  • Re: Dynamic loading of javascript files into web pages
    ... It is less safe because of the use ... than a <script> tag? ... var x = 'outer'; ...
    (comp.lang.javascript)
  • Re: New Meds...
    ... It's the DEA who wants the 3 month script writing. ... down isn't safe for what we would need one for. ... we get three month supplies of meds from THEIR mail in pharmacies, ... I still only see my doctor every 3 months. ...
    (alt.support.chronic-pain)
  • Re: RFD: How To Recognize Bad Javascript Code
    ... Elements consist of tags ... Your example `script' elements are empty where they should have ... | Using the pseudo-protocol javascript in the href is never valid. ... Some web developers use this to work ...
    (comp.lang.javascript)
  • Re: Community problem
    ... >I belong to a small web community that is based around a horse racing game. ... >On the site we have a disscussion forum for the members to post messages, ... The script he uses is placed in the message ... Any unclosed tag in the same position would probably do the same. ...
    (comp.lang.javascript)

Loading