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


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:
. on this page there is an iframe

2. Page 2:
. 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



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.

    function showcontent() {
        document.getElementById("icontent").src = "TargetPage.aspx";
        return false;

<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.

    $(function () {
        $("#btnshowcontent").click(function () {
            $("#DivContent").load("TargetPage.aspx #content2");
            return false;

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

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 :


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