Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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">
  .Myframe
  {width:100%; height:expression(document.body.clientHeight-100);}
</style>
<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= 'http://mywebsite/page.aspx';
</script>

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

share|improve this question
    
    
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. –  Matt 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 MCSE Aug 26 at 5:10

2 Answers 2

up vote 2 down vote accepted

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">
(function(){
    var D = document;
    //http://james.padolsey.com/javascript/get-document-height-cross-browser/
    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)
    );

    //http://stackoverflow.com/a/935537/98933
    var parentFrame = parent.document.getElementById(window.name);
    parentFrame.style.height = dheight + 'px';
})();
</script>

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

share|improve this answer

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 :-)

share|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! –  BGM Aug 25 at 22:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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