0

I have a main.php file that contains two iframes: test1 and test2

<iframe id="test1" name="test1" src="test1.php" height="300" width="200"></iframe> 
<iframe id="test2" name="test2" src="test2.php"></iframe>

The #test1 contains display: none;

I would like to display the content of test1.php when a button at test2.php is clicked. I have tried a number of options and referred to previous posts related to this issue but couldn't load test1.php. How can I accomplish this?

glts
  • 19,167
  • 11
  • 65
  • 85
tamirat
  • 1
  • 1
  • iframes are almost always a bad idea, easily replaced. –  May 21 '13 at 21:23
  • I don't believe this is possible unless the page in the click event iframe is on your server and it sends an ajax request that the page in your other iframe is polling to. – km6zla May 21 '13 at 21:24

2 Answers2

0

Edit: I'm unsure about what you mean by "load". Is the content of the other div loaded initially, and you're just trying to change its visibility? Or are you trying to change the whole contents of the iframe?

Case 1: If you're trying to change the visibility of contents that are already loaded in an iframe when you click the button, then check this question: Javascript - Get element from within an iFrame

Once you access the element you wish, you can easily modify its display attribute

Case 2: If you're trying to change the whole contents of the iframe when you click the button, you need to change its src attribute. Check this question for an answer: Changing iframe src with Javascript

Community
  • 1
  • 1
Filippos Karapetis
  • 4,197
  • 19
  • 36
0

use jquery , when a button on test2 is clicked make test1 display block and test2 display none and vice versa $('#buttontest2').click(function() { $('#test1').css('display' : 'block'); })

Haben
  • 97
  • 5