Embedding other sites in a SharePoint page

June 7th, 2008 | Tags:

I had this typical situation where I had to embed a totally different site into a SharePoint page. This is the way I did it using SharePoint designer.

1. Open the site in SharePoint designer.

2. Create a new page using ‘File->New->ASPX’.

3. Attach the master page using Format -> Attach Master Page. (I use the minimal master page since I had to fully customize the layout).

4. Put the “iframe” tag inside the <asp:content PlaceHolderMain>

5. Write a small javascript for resizing and call this using the “_spBodyOnLoadFunctionNames” function.

5. My page source would look like this.

<asp:Content id="Content1" runat="Server" contentplaceholderid="PlaceHolderMain">
<SharePoint:ScriptLink language="javascript" name="core.js" runat="server"/>

<iframe name="I1" id="I1" frameborder="0" bordercolor="#FFFFFF" marginheight="0" marginwidth="0"
scrolling="no">
Your browser does not support inline frames or is currently configured not to display inline frames.

</iframe>

</asp:Content>
<asp:Content id="Content2" runat="server" contentplaceholderid="head">

<title>Viw Flight details</title>
<script type="text/javascript">

function resizeFrame()
    {
        var fr = document.getElementById("I1");
        if (fr == null) return;

        var str = window.location + "";

        fr.width = screen.availWidth - 100;
        fr.height = screen.availHeight - 100;

        var iPos = str.indexOf("myquerystring");
        //alert(iPos);
        var subs = str.substring(iPos, str.length);
        fr.src = "https://www.somesite.com/parameter?" + subs;
        //window.open(fr.src);
    }

_spBodyOnLoadFunctionNames.push("resizeFrame");

</script>
</asp:Content>
No comments yet.