Connect.Collaborate.SharePoint

Alternative to the SharePoint Page Viewer Web Part to solve the height problem

Have you ever wanted to host another web application within the SharePoint chrome using the Page Viewer Web Part but been frustrated by the dual scroll bars?
 
My solution is an aspx page that has an iFrame that uses a css style to set the height of the iFrame based on the current browser height. The src attribute for the iFrame is taken from the url.
This means that you can create standard SharePoint menu items that call this page and specify the url to be loaded in the iFrame.
 
Just copy this code into Notepad and save into a SharePoint library as an aspx file.
 
<%@ Page masterpagefile="~masterurl/default.master" language="C#" title="Untitled 1" inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" meta:progid="SharePoint.WebPartPage.Document" %>
<%@ Register tagprefix="WebPartPages" namespace="Microsoft.SharePoint.WebPartPages" assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<asp:Content id="Content1" runat="server" contentplaceholderid="PlaceHolderMain">
<style type="text/css">
.Myframe
 {width:100%; height:expression(document.body.clientHeight-160);}
</style>
<script type="text/jscript" language="javascript">
 function getParameter(szName)
 {
  // Get value out of supplied parameter
  var szUrl = window.location.search;
  szUrl = szUrl.toLowerCase();
  szName = szName.toLowerCase();
  var szValue = "";
  var nBegin = szUrl.indexOf(szName);
  if (nBegin != -1)
  {
   szValue = szUrl.substring(nBegin + (szName.length + 1));
  }
  var nEnd = szValue.indexOf("&");
  if (szValue != "" && nEnd != -1)
  {
   szValue = szValue.substring(0, nEnd);
  }
  return szValue;
 }
</script>
<iframe id="I1" name="I1" class="Myframe" width="100%" frameborder="0" >
Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe>
<script type="text/jscript" language="javascript">
 I1.location.href= getParameter('url');
</script>
</asp:Content>
 
If you want to use this for something like hosting Reporting Services pages which have very long url's, you could change the parameter to "report" and prefix the I1.location.href value with the consitant part of the applications url.
e.g.  I1.location.href= '/Reports/_layouts/ReportServer/RSViewerPageNoHeader.aspx?RelativeReportUrl=/reports/reportslibrary/' + getParameter('report');
Posted by Ian Morrish on Friday, 27 Apr 2007 08:13 | 1 Comments
SharePoint

Links to this post

Trackback from Blog on 12 Apr 2008 08:58

Name

Url

Email

Comments

CAPTCHA Image Validation