Pageviewer webpart dynamic resizing

Posted on 2009-12-17
Last Modified: 2012-06-22

I would like to know how to resize a sharepoint pageviewer webpart content dynamically. Scenario below -
I have installed WSS 3.0 and created a site(menu) ABC and inserted a pageviewer webpart and redirect URL :\abc.aspx(located on the same server), and also I inserted a content editor webpart to add scripts.
I need the abc.aspx page to fit in dynamically according to the screen resolution, how could this be done, any help will highly appreciated.
Please provide scripts so that I can test it

Question by:roisroy

    Author Comment

    I am still searching for a solution!
    Experts pls respond

    LVL 51

    Expert Comment

    The Page Viewer Web Part is essentially an IFRAME, however, Sharepoint might implement some tricks to force it to fit in the page.  If you can't control the IFRAME using CSS then I suspect it can't be done.
    LVL 15

    Accepted Solution

    You can do it using JavaScript code. Generally you need to add the "window.onresize " tag to your script and fire some function with it what will change the dimensions of your IFrame.
    Depending on your needs you will have to calculate the IFrame size appropriately to the object it is nested in. Make sure the main object is changing it's size dynamicaly to fit the page size (so for ex. height and width set to 100%.).
    I would recomend switching from the web page viewer to the simply putting your code on the page - it will be easier for you to control the iframe. Use the SPD to put the code from the snippet on our page.
    Using web parts for this might be complicated - webparts do not scale to fit the page in heigth - they tend to scale to 0. So you either need to artificialy pump their heigth or not use web part and put the code on page with SPD.

    <table cellspacing=0 cellpadding=0 border="1" height="100%" width="100%"><tr><td id="td_with_iframe"><iframe id="iframe" src=""></iframe></td></tr></table>
      //attach the setIframeDimensions() function to the window resize event
      //set the iframe object
      //fire the function to fit the iframe when page loads
      //define the setIframeDimensions function that will resize the Iframe in relation to the nesting object
      function setIframeDimensions()
    	//scale down the iframe to get the real parent size (in case of resizing down)
    	//scale to parent size

    Open in new window


    Author Comment

    Dear DB_Expert,
    Thanks for the script and suggestions, I will try it and get back to you.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
    JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
    This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now