Advertisement

07.07.2008 at 04:06PM PDT, ID: 23545066
[x]
Attachment Details

Passing a Value from Iframe's Soure Page Up to Page Holding the IFrame: How?

Asked by JaeWebb in JavaScript, Dynamic HTML (DHTML), Asynchronous Javascript and XML (AJAX)

Tags: ,

I have a JavaScript solution that relies on a sub-page that is loaded into an iframe.  The JavaScript file is linked in two places; the sub-page and in the container-page that contains the iframe.  While the sub-page is loading, a script block is executed in order to set a variable in the JavaScript file.  The problem is that after the sub-page is done loading, the container-page begins processing without access to the variable set in the sub-page.  The two container-page and sub-page both link to the same JavaScript file but they are creating separate instances of the needed variable.

I need to maintain the state of the variable across both pages, like a static variable, or to pass the value from the sub-page up to the container-page.  Does anyone have any idea if and how this can be accomplished?

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
<html>
<head>
<script type="text/javascript" language="javascript" src="demo.js"></script>
<script type="text/javascript">
	window.onload = containerPage();
</script>
<style>
	p {width:600px;font-size:14pt;}
</style>
<title>Shared JS Variable Demo | Container Page</title>
</head>
<body>
 
 
<div id="container" style="position:absolute;top:100px;left:300px;">
  <div id="message">
	<p>For some reason, the live page where I'm using this function fires the 
	iFramePage() function before the page containerPage() function fires, so 
	ideally the solution would be bi-directional, meaning I could set the sharedVar
	from either page if need be.</p>
	<p>My solution requires that I use the iFrame's sub-page to set the variable.</p>
  </div>
  <div id="content"></div>
  <iframe id="theIframe" name="theIframe" src="subpage.html" onLoad="iFramePage();"
    width="0" height="0" scrolling="no" frameborder="0" marginheight="0" marginwidth="0" allowTransparency="true"></iframe>
</div>
 
 
</body>
</html>
Attachments:
 
Remove the 'TXT' extention and place the file in the same directory all the files in the same directory
 
 
Remove the 'TXT' extention and place the file in the same directory all the files in the same directory
 
 
Remove the 'TXT' extention and place the file in the same directory all the files in the same directory
 
 
 
[+][-]07.07.2008 at 05:49PM PDT, ID: 21949897

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: JavaScript, Dynamic HTML (DHTML), Asynchronous Javascript and XML (AJAX)
Tags: JavaScript, All (IE7, IE6, Firefox, etc.)
Sign Up Now!
Solution Provided By: srikanthmadishetti
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.07.2008 at 06:00PM PDT, ID: 21949936

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.07.2008 at 06:02PM PDT, ID: 21949941

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.07.2008 at 06:06PM PDT, ID: 21949949

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.07.2008 at 06:07PM PDT, ID: 21949954

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628