Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass data between iframe and main window

Status
Not open for further replies.

maxpower1

Programmer
Jul 29, 2001
488
US
does anyone have some codes that pass data between iframe without using href? For example, using window.setInterval,
a function will be called to pass the value from the main window to the window inside iframe?

thx
 

Here is my quick answer - from experience only - nI hope a real expert will come along next.

You can do many things in iframes AND you are restricted from doing many things for security reasons.

If the page you have in the iframe comes from the same directory and the same site as the main webpage that contains the iframe, lots can be done.

You can even iframeid.write('<body>hello');

into an empty iframe.

But don't expect to be able to &quot;copy&quot; contents of other wesbites that you load into the iframe.

I'm not sure what you are trying to do, but hope this helps.

Please be more specific.
 
thx. Here is what I want to do. I want to assign the
value hello to the txt1 on a.html. I can't really use href because the event is based on the timer(with the things I want to accomplish, I cannot use href>. for instance:-

in b.html
----------------
<script>
function refresh() {
//i can't figure out this part
//it kept giving me document.frm1 is
//not defined or null
document.if1.document.frm1.txt1.value = &quot;hello&quot;;
}

<body>

<iframe src=&quot;a.html&quot; id=&quot;if1&quot;>
</frame>
<script>
window.setInterval(&quot;refreshData&quot;, 5000);
</script>
</body>

in a.html
---------
<body>
<form id=&quot;frm1&quot;>
<input type=&quot;text&quot; id=&quot;txt1&quot;>
</input>
</form>
</body>

thx
 
alright. I found the solution. for those who wonder,here is how to do it:-


in b.html
-------------------------------------
<html>
<head>
</head>
<body>
<form id=&quot;frmParent&quot; name=&quot;frmParent&quot;>
<input id=&quot;txtInput&quot; name=&quot;txtInput&quot; value=&quot;helloooooooooo&quot;>
</input>
</form>
<iframe id=&quot;fr1' name=&quot;fr1&quot; src=&quot;b.html&quot;>
</iframe>
</body>
</html>





in a.html
----------------------
<html>
<head>
</head>
<body>
<script>
alert(window.top.document.forms['frmParent'].txtInput.value);
</script>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top