[RESOLVED]create a link to a content that will open in an iframe

Hi,

is it possible to create a link to content that will open in the iframe of a specific page?

say I have this:

1. Page 1:
http://domain.com/Integrated/Index?HtmlElementId=tge_pnl&GroupHtmlElementId=tile2Tile
. on this page there is an iframe

2. Page 2:
http://anotherdomain.com/Variance/Index/b8b85b6f-3e9a-482c-bba1-900b92b2a308
. on this page there is content that i’d like to show on the iframe of Page 1

is it possible to create a link that will open Page 1 and show page 2 in the iframe section.

Please not that I need this to be dynamically created. i.e. the content that will show on the iframe will change depending on the ‘news letter’ link a user receives. in any case i’d like that content to appear within the context of the iframe instead of a standalone
page.

doable?

Krs

Hi Awillys,

Thanks for your post.

Firstly, if you’d like to dynamically set src property of iframe to show a page as a subwindow, you could try the below code.

<script>
    function showcontent() {
        document.getElementById("icontent").src = "TargetPage.aspx";
        return false;
    }
</script>

<iframe id="icontent"></iframe>
<br />
<asp:LinkButton ID="btnshowcontent" runat="server" OnClientClick="return showcontent();">news letter</asp:LinkButton>

Secondly, if you want to load page fragments, you could try the following code.

<script>
    $(function () {
        $("#btnshowcontent").click(function () {
            $("#DivContent").load("TargetPage.aspx #content2");
            return false;
        })
    })
    }
</script>


<div>
    <div id="DivContent">
    </div>
    <br />
    <asp:LinkButton ID="btnshowcontent" runat="server">news letter</asp:LinkButton>
</div>

For more information about .load() method, you could refer to the below link.

Hope it will be helpful to you.

Best Regards,

Fei Han

Hi Awillys,

Yes I believe that can be done using the src attribute of the iframe tag, please try the following code :

document.getElementById('contentHolder').setAttribute("src","https://www.mirror.co.uk");
  

contentHolder is the id for the iframe tag.

Sample Working Demo

You can replace https://www.mirror.co.uk by your Page2 

Hope it helps

Leave a Reply