0

I added an iframe in my webpage. I want to add a div inside of that iframe. But i have not been able to do so. If anyone can help me with this one, i would be very thankful. The code that i used is given below.

`<div class="text-column">
    <?php
        $url="https://secure.activecarrot.com/public/facility/index/33/768";
    ?>
    <iframe src="<?php echo($url); ?>" width="100%" height="1000px" frameborder="0"></iframe>
</div>`
Rabyn
  • 11
  • 1
  • 3
  • If content of iframe is loaded from another domain, you can not do it for security reasons. – Cheery Sep 30 '14 at 03:51

2 Answers2

0

You will need to use Javascript to inject the content into your iframe after the page has loaded: \

Create an <iframe> element and append html content to it with jQuery

However, be careful appending to an iframe: the third party using it probably expects to send and receive the same content, and injecting code into it may cause whatever function it performs to fail.

Edit: others have cited security concerns, and they are justoified. However, it is technically possible to do what OP hs requested.

You need to inject the content after the page has loaded because the iframe pulls and overwrites content on page load. If the iframe does not need to send anything back to the server at any point there is no reason you cannot add extra elements to an iframe. Every case is different.

Community
  • 1
  • 1
Ucinorn
  • 648
  • 7
  • 21
-1

I am afraid you will not be able to do this, since iframe is a way to inculde an external page (to put it simple), hence you can not alter pages in iframes.

Regards, Spyros

Spyros
  • 313
  • 4
  • 12