Not in the browser. The Rhino JavaScript platform gives you all kinds of access to areas and contexts, though (via Java).
Why do you need to access this area?
If you want to execute a piece of code with access to the properties of a specific object, you can always use eval and with (with their performance flaws included).
function exec(obj, func) { with (obj) { eval("("+func+")()"); } } var actObj = { annoying: function (txt) { alert(txt); } }
If you want to execute code in specific content, without an object, just define a function inside this scope that you can execute from the outside.
For instance:
var module = (function () { var a = 2; var peek = function (fn) { eval("("+fn+")()"); } return { peek: peek } })(); module.peek(function () { alert(a); });
source share