-1

I have an index page which has two iframes.

<iframe name="disp" id="dispframe" src="disp.php"></iframe>
<iframe name="type" id="msgframe" src="type.php"></iframe>

Now in type.php which is the bottom iframe, if I type some message and on submit, I want to change a particular div in the top iframe. (basically refresh contents from another file)

I could achieve a refresh by using: (and everytime during refresh, the new content for that div is fetched)

<script type="text/javascript">
parent.disp.location='disp.php'
</script>

But I want to change only a div in disp.php (say with id="loaddiv"). If I was to do it within disp.php itself, I would use something like this:

$('#loaddiv').load('newdisp.php');

Now I want to access loaddiv from the other iframe. I tried some things which didn't work.

$("#dispframe", parent).contents().find("#loaddiv").load("newdisp.php");

I know I'm wrong somewhere. Anybody can help with the right DOM traversal method?

Quik Tester
  • 347
  • 1
  • 5
  • 16
  • This question already asked!Please verfy http://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe – sathishkumar Jan 25 '12 at 12:10
  • I want to access contents of one iframe from another iframe. Not just the contents of an iframe from the parent. How do I access the sibling iframe from this iframe? – Quik Tester Jan 25 '12 at 12:23

1 Answers1

0

This can be fine.

var ele = window.top.IFRAME_NAME.$("#YOUR_ID");

//here you can do whatever with jquery //example ele.show();

sathishkumar
  • 1,780
  • 4
  • 20
  • 31