...

View Full Version : Possible for a script in IFRAME to access and write text on the page containing it ?



Johds
10-07-2003, 02:44 PM
Sirs,

Is it possible for a script contained in a HTML page in an IFRAME tag, to write dynamic data to the page containing the IFRAME tag ?

Example of the main page:
<html>
<head>
</head>
<body>
<iframe name=dodata src="foo.html" frameBorder=0
width=50 scrolling=false height=20 scrolling=no allowTransparency></iframe>
<p id=rewrite> This data should be rewritten <p>
</body>
</html>

example of the IFRAME page:
<html>
<head>
</head>
<body>
<script>
javascript statements to access the "rewrite" object in the main page, and write "hello world" or something similar
</script>
<p> Processing test, stand by
</body>
</html>

Or is the page loaded in the iframe tag only able to access objects in it self ?

Thanks in advance

Johds

Willy Duitt
10-07-2003, 04:08 PM
You can refer to an IFRAMES Parent by referencing
parent.document as opposed to self.document

Here's (http://www.pxl8.com/iframes_3.html) a Tute you may find helpful.

...Willy

af11kcc
10-07-2003, 06:15 PM
I have done something similar for a shopping cart. In that case I used text fields (borderless) in order to change some labels according to changes made on the iframe...for example:

window.parent.document.frmNota.txtScan.value = document.frmShopCart.txtDescrition.value



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum