<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Help me get a handle on my frames!</title>
	<link>http://ask.metafilter.com/105717/Help-me-get-a-handle-on-my-frames/</link>
	<description>Comments on Ask MetaFilter post Help me get a handle on my frames!</description>
	<pubDate>Fri, 31 Oct 2008 22:48:02 -0800</pubDate>
	<lastBuildDate>Fri, 31 Oct 2008 22:48:02 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Help me get a handle on my frames!</title>
		<link>http://ask.metafilter.com/105717/Help-me-get-a-handle-on-my-frames</link>	
		<description>HTML/DOM/JavaScriptfilter:  Help me get a handle on my frames!  I&apos;m by no means a javascript expert, though I can bash my way around in it when necessary - but I just can&apos;t figure out how to get a handle on the frames in my document via the DOM. &lt;br /&gt;&lt;br /&gt; I&apos;m trying to wrapper a pre-written app that I host (but have no control over and can&apos;t modify) in an IFRAME (for a couple of reasons), and want to register event handlers programatically on the frames of the app (to detect when the user is active in the app).  The resultant page looks somewhat like &lt;a href=&quot;http://jferg.lusars.net/frames/iframe.html&quot;&gt;this&lt;/a&gt;.  I&apos;m trying to register event handlers on the nav and view frames from JavaScript in the top-level document, but cannot figure out how to traverse the DOM to get an object for the documents within the frames.  I can&apos;t even use getElementById, because there are no IDs defined on the frames within the app.  (But I&apos;d rather have a generic solution that will work no matter what the frames are named.)  FireBug is providing me with no assistance on this one, either.  Can any of you MeFi HTML DOM wizards out there help?</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2008:site.105717</guid>
		<pubDate>Fri, 31 Oct 2008 20:00:16 -0800</pubDate>
		<dc:creator>jferg</dc:creator>
		
			<category>html</category>
		
			<category>javascript</category>
		
			<category>dom</category>
		
	</item> <item>
		<title>By: Pinback</title>
		<link>http://ask.metafilter.com/105717/Help-me-get-a-handle-on-my-frames#1526531</link>	
		<description>Iframes are a bit odd because, being frames, they&apos;re more children of the window than of the parent document. IIRC, if you&apos;ve got no IDs, you need to do something along the lines of &lt;code&gt;window.frames&lt;/code&gt; get an array of all the frames/iframes, then dig through the array to find the right ones (hopefully your app doesn&apos;t create them in a different order in each page!). Once you&apos;ve found the right ones in the array, it&apos;s then a matter of using something like &lt;code&gt;window.frames[x].document.&lt;em&gt;property&lt;/em&gt;&lt;/code&gt; to access them (e.g. &lt;code&gt;window.frames[1].document.title&lt;/code&gt; returns the first iframe&apos;s title).&lt;br&gt;
&lt;br&gt;
&lt;small&gt;(Don&apos;t quote me on that, though, because the last time I did this iframes were a new invention, and the whole DOM thing was &lt;em&gt;very&lt;/em&gt; immature...)&lt;/small&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.105717-1526531</guid>
		<pubDate>Fri, 31 Oct 2008 22:48:02 -0800</pubDate>
		<dc:creator>Pinback</dc:creator>
	</item><item>
		<title>By: qvtqht</title>
		<link>http://ask.metafilter.com/105717/Help-me-get-a-handle-on-my-frames#1526534</link>	
		<description>If the iframe page is coming from a different domain than the parent page, you won&apos;t be able to access or manipulate it with javascript due to cross-domain security.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.105717-1526534</guid>
		<pubDate>Fri, 31 Oct 2008 23:01:30 -0800</pubDate>
		<dc:creator>qvtqht</dc:creator>
	</item><item>
		<title>By: jferg</title>
		<link>http://ask.metafilter.com/105717/Help-me-get-a-handle-on-my-frames#1526622</link>	
		<description>window.frames only seems to contain the iframe, not the frames in the frameset contained _in_ the iframe.  &lt;br&gt;
&lt;br&gt;
And qvtqht, the app is hosted from the same host/domain as the parent page - I just have no control over the code for the app.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.105717-1526622</guid>
		<pubDate>Sat, 01 Nov 2008 06:12:06 -0800</pubDate>
		<dc:creator>jferg</dc:creator>
	</item><item>
		<title>By: ook</title>
		<link>http://ask.metafilter.com/105717/Help-me-get-a-handle-on-my-frames#1526733</link>	
		<description>If you&apos;re trying to get frames within frames, then just keep travelling down the object chain until you have the one you want: window.frames[x].frames[x]... and so on.  IDs are less fragile than indexes, but sometimes you just have to work with what you have.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.105717-1526733</guid>
		<pubDate>Sat, 01 Nov 2008 09:07:02 -0800</pubDate>
		<dc:creator>ook</dc:creator>
	</item><item>
		<title>By: jferg</title>
		<link>http://ask.metafilter.com/105717/Help-me-get-a-handle-on-my-frames#1526802</link>	
		<description>ook:  That&apos;s what I thought too!  But when I dig around in the DOM using FireBug, window.frames == window.frames.frames.frames.frames.frames.frames ad nauseum.  That&apos;s the part I don&apos;t get.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.105717-1526802</guid>
		<pubDate>Sat, 01 Nov 2008 10:50:31 -0800</pubDate>
		<dc:creator>jferg</dc:creator>
	</item><item>
		<title>By: ook</title>
		<link>http://ask.metafilter.com/105717/Help-me-get-a-handle-on-my-frames#1526947</link>	
		<description>You have to identify the specific frames you&apos;re after (by treating each &apos;frames&apos; as an array).&lt;br&gt;
&lt;br&gt;
In your &lt;a href=&quot;http://jferg.lusars.net/frames/iframe.html&quot;&gt;test page&lt;/a&gt;:&lt;br&gt;
window.frames[0] == frameset.html&lt;br&gt;
window.frames[0].frames[0] == nav.html&lt;br&gt;
window.frames[0].frames[1] == view.html&lt;br&gt;
window.frames[0].frames[0].document.body.innerHTML == &quot;This is the view frame!\n&quot;;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.105717-1526947</guid>
		<pubDate>Sat, 01 Nov 2008 14:34:49 -0800</pubDate>
		<dc:creator>ook</dc:creator>
	</item><item>
		<title>By: jferg</title>
		<link>http://ask.metafilter.com/105717/Help-me-get-a-handle-on-my-frames#1528275</link>	
		<description>ook:  Thank you!  Apparently firebug&apos;s DOM inspector is just plain weird, and was showing me something other than what I was expecting in the case of the frames array.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.105717-1528275</guid>
		<pubDate>Mon, 03 Nov 2008 07:44:36 -0800</pubDate>
		<dc:creator>jferg</dc:creator>
	</item>
	</channel>
</rss>
