I want to insert another web page inside a SP2010 page. With "Page Viewer Webpart", it only takes a small portion of the vertical space available on my SP page.

I had the same problem in SP2007, and solved it with:

<style type="text/css">
  {width:100%; height:expression(document.body.clientHeight-100);}
<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.
<script type="text/jscript" language="javascript">
  I1.location.href= 'http://mywebsite/page.aspx';

Now, in SP2010, I can't reproduce the same behavior.
Any solutions for this simple requirement?

  • I've worked with this code and can't get it to work. Also, the content editor does not have the source editor in SP 2010 as far as I can tell. I have tried programatically adding the content editor and using variations of the javascript to no avail. – Matthew Steven Monkan Feb 8 '11 at 23:37
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Waqas Sarwar MVP Aug 26 '14 at 5:10

Neither of the answers really worked for me... so I came up with my own script. Put this inside the page you are displaying using the Page Viewer Web part near the end; probably right before the </body> tag.

<script type="text/javascript">
    var D = document;
    var dheight = Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)

    var parentFrame = parent.document.getElementById(window.name);
    parentFrame.style.height = dheight + 'px';

It works by getting the parent document, looking up the iframe it lives in and setting the iframe height to be a static value.

| improve this answer | |
  • I put this code just like it is in a master page inside of my $(document).ready(function () and it works! I never set the height property on the webpart and when I load pages into it, the scrollbars disappear! Wonderful! I'd give another +1 if I could. However, if you have another iframe on the underlying page, you'll see it's scrollbars. – bgmCoder Sep 10 '14 at 21:34

took me a long time to find out what to do, but I solved it. It has to do with the DocType and rendering. I removed the XHTML doctype from a custom masterpage and set from 8 to 7.

Now the rendering works again. Maybe the HTML doctype can be put in place of the XHTML one, maybe the rendering can be put to 8 - but it works for me - and i dont want to look at it anymore :-)

| improve this answer | |
  • 3
    Can you explain with more detail how you solved it? Thanks. – Nelson Reis Oct 26 '10 at 15:38
  • Please do add some details! You are teasing us! – bgmCoder Aug 25 '14 at 22:30
  • Yes, yes, Please do explain further! – bgmCoder Sep 10 '14 at 21:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.