For possible amusement, I spent half a day yesterday spelunking into
the world of various ways to install code in a web browser.  Details
are here:

http://lexspoon.blogspot.com/2009/03/many-scopes-of-javascripts-eval.html


My initial idea to use window.eval turns out to be terribly
non-portable: it only evaluates at window scope on Firefox.  Instead,
I'm thinking to use the following code to install newly downloaded
code:

if (window.execScript) {
  window.execScript(script)
} else {
  var tag = document.createElement("script")
  tag.type = "text/javascript"
  tag.text = script
  document.getElementsByTagName("head").item(0).appendChild(tag)
}


The first branch is for window.execScript, which is available on IE
and, of all things, Chrome.  They are such similar browsers, you know.
 The second branch works on all browsers, but it's ugly enough that I
didn't want it to be used all the time.  Maybe that's silly, and only
the second branch should always be used.

Any thoughts or better ideas?

Lex

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to