D3: what am I, as in d3.select (self.frameElement) .style ("height", height + "px");

I have seen statements like the ones below in many D3 examples. However, I cannot understand what this means. In particular, I do not know what this variable self refers to. Also, is this some kind of D3 dummy / agreement or is it just a special thing? Thank you very much.

 d3.select(self.frameElement).style("height", height + "px"); 

BTW, here is an example where I copied the above statement.

+8
javascript
source share
2 answers

self : if not overridden (usually as a copy of this ) than the window object, which always points to window . Therefore, they can be used interchangeably.

window.frameElement : Returns the element (for example, <iframe> or <object) into which the window is embedded, or null if the window is at the top level.

See Window.frameElement

+6
source share

In this example, I found the following comment:

 // Hack to make this example display correctly in an iframe on bl.ocks.org 
+3
source share

All Articles