简体   繁体   中英

How to find the Vertical size of a window displaying a web page

I have an ASP.NET Site that has a single Master Page. On one of my pages in this site I display a PDF file as the content of the page.

I need a way to know the size that I can make the PDF control so that I do not create a scroll bar for the webpage (the PDF control has it's own scroll bar).

I was able to solve this horizontally by setting the width of the control to 100%. Sadly this does not work for the Vertical size.

Any help is appreciated.

Vaccano

There's no way to determine this server-side, so you'll need to use JavaScript. I'd recommend the jQuery Dimensions plug in .

If you do use JavaScript, however, there is a workaround where you can put that value into a HiddenField (Which of course JavaScript would see as an Input), and click a Submit button, all behind the scenes. If you use an UpdatePanel, you may be able to get away with a partial postback without user intervention.

For the button clickery, look into Document.Forms[0].btnMyButton.Click();.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM