0

How to change the height and width of a Page Viewer web-part based on the size of the content?

Regards, Korak

1
  • Did you tried below solution?
    – Hardik
    Jun 28, 2016 at 11:55

2 Answers 2

1

You can user below script in ScriptEditor webpart below your Page Viewer WebPart to make show it in full page view.

<script language=”javascript”>
var a = MSO_ContentTable.getElementsByTagName(“table”);
MSO_ContentTable.setAttribute(“height”,“100%”);
for(i=0;i<a.length;i++)
{
 a[i].setAttribute(“height”,“100%”);
}
var z = document.getElementsByTagName(“div”);
for(i=0;i<z.length;i++)
{
 if(z[i].id.indexOf(“WebPartWPQ”,0) >=0 )
 {
  if(z[i].hasChildNodes())
  {
   if(z[i].firstChild.nodeName.toUpperCase() == “IFRAME”)
   {
     z[i].firstChild.setAttribute(“height”,“100%”);
   }   
  }
 }
}
</script>

For further information, Please check below mentioned MSDN article.

Story of a mischievous Page Viewer Web Part

If you want to set only height to 100% thank kindly check below link

Setting height to 100% in Page Viewer Webpart

1
  • Did you tried above code? Is that works for you?
    – Hardik
    Jun 27, 2016 at 12:46
0

Here is a library that can help you: https://github.com/davidjbradshaw/iframe-resizer

In this package there are two JS-files, one for the host (SharePoint) and one for the page that you want to show in the iframe. Once both scripts are implemented they will start to negotiate a size for the iframe so that all the content fits inside.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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