Location hack: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
(comment2,)
(comment6,)
Line 11: Line 11:
comment2,
comment2,


== Returning values ==
comment6,
 
The location hack is really handy for passing values to the content scope, or to call functions defined there.
It is not, however, capable of directly reading a variable or value returned from a function.
Furthermore, it is run asynchronously, much like <code>setTimeout()</code>, so you cannot immediately rely on side effects.
(If you use the location hack to, for example, store a value in the DOM and then attempt to read it, it will only be available at some other later point in time.)
For reading javascript values from the content scope inside the sandbox, see [[Reading Content Globals]] for a reliable example.


== See Also ==
== See Also ==

Revision as of 13:46, 9 August 2011

The location hack is an ugly but useful way to interact with the content scope of the page being user scripted. It does this by indirectly evaling strings within that scope.

comment5,

comment4,

comment4,

comment4,

comment2,

comment6,

See Also