﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Programming By A Tool &#187; iframe</title>
	<atom:link href="http://byatool.com/tag/iframe/feed/" rel="self" type="application/rss+xml" />
	<link>http://byatool.com</link>
	<description>This is my recorded stumbling through ASP.Net, Framework 3.5, C# 3.0, Ajax, Javascript, and Love.  Stay, learn, destroy.  It's your life.</description>
	<lastBuildDate>Thu, 03 May 2012 17:28:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Child IFrame Page Interacting with Parent Page&#8230; Yeah I went there.</title>
		<link>http://byatool.com/lessons/child-iframe-page-interacting-with-parent-page-yeah-i-went-there/</link>
		<comments>http://byatool.com/lessons/child-iframe-page-interacting-with-parent-page-yeah-i-went-there/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 20:07:54 +0000</pubDate>
		<dc:creator>Sean</dc:creator>
				<category><![CDATA[Lessons]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://byatool.com/?p=1241</guid>
		<description><![CDATA[Example here. File this under &#8220;Why?&#8221; but I wanted to see if a child could talk to a parent and then receive information back from the parent to update itself with. As usual, my lack of intelligent wording probably has you scratching your head&#8230; if you do that. Personally I don&#8217;t get that expression as [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.byatool.com/Hosted/LiveDemos/JavascriptIframeDelegate/Parent.htm">Example here.</a></p>
<p>File this under &#8220;Why?&#8221; but I wanted to see if a child could talk to a parent and then receive information back from the parent to update itself with.  As usual, my lack of intelligent wording probably has you scratching your head&#8230; if you do that.  Personally I don&#8217;t get that expression as when I&#8217;m confused I more than likely will grab a jar of peanut butter and start lathering up with it, but to each his own.</p>
<p>So here&#8217;s the idea, and this post is only the start.</p>
<p>You have a parent page, Parent.htm, with an iframe and you want the parent to do something and alert the child that something happened.  For now, it&#8217;s actually really simple.</p>
<p>On the parent I have a method:</p>
<pre>  <span style="color: #0000ff;">function</span> callMethod(text, methodDelgate) {
    <span style="color: #0000ff;">if</span> (methodDelgate != <span style="color: #0000ff;">null</span>) {
      methodDelgate(text);
    }
  }
</pre>
<p>And this simple markup:</p>
<pre>  &lt;iframe id="myFrame" src="Child.htm"&gt;&lt;/iframe&gt;
</pre>
<p>Wow huh?  Well on the child I have this:</p>
<pre>  <span style="color: #0000ff;">function</span> callParent(text) {
    <span style="color: #0000ff;">if</span> (top.callMethod != <span style="color: #0000ff;">null</span>) {
	  top.callMethod(text, changeText);
    }
  }
</pre>
<p>This is easy.  If the parent has the method, send the text through and a method to call when finished.  What is this method?  Well its:</p>
<pre>  <span style="color: #0000ff;">function </span>changeText(text) {
    jQuery(<span style="color: #800000;">'#returnText'</span>).text(text);
  }
</pre>
<p>Which simply sets the text on some div to show it actually worked.</p>
<p>What happens when I click a button that calls callParent?  It talks to the parent, the parent calls the passed in method, and the child updates itself.</p>
<p>Not sure this is rocket science, but there will be more on it as I add in the idea of a dynamically created pop up on the parent being used by the child.  Until then, try not to be yourself.  You embarrass your mother.</p>
]]></content:encoded>
			<wfw:commentRss>http://byatool.com/lessons/child-iframe-page-interacting-with-parent-page-yeah-i-went-there/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

