admin管理员组

文章数量:1287274

I have seen statements like below in many D3 examples. However, I can't find out what it means. In particular, I don't know what this self variable refers to. Additionally, does this manifest some sort of D3 magic/convention or is it just an ad-hoc thing? Thank you very much.

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

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

I have seen statements like below in many D3 examples. However, I can't find out what it means. In particular, I don't know what this self variable refers to. Additionally, does this manifest some sort of D3 magic/convention or is it just an ad-hoc thing? Thank you very much.

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

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

Share Improve this question asked Mar 17, 2014 at 6:15 JBTJBT 8,75621 gold badges68 silver badges107 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

self: if not redefined (typically as copy of this) than it is window object which always points to window. So they can be used interchangeably.

window.frameElement: Returns the element (such as <iframe> or <object>) in which the window is embedded, or null if the window is top-level.

See Window.frameElement

On this example I found the following ment:

// Hack to make this example display correctly in an iframe on bl.ocks

本文标签: