简体   繁体   English

如何找到显示网页的窗口的垂直大小

[英]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.我有一个只有一个母版页的 ASP.NET 站点。 On one of my pages in this site I display a PDF file as the content of the page.在本网站的其中一个页面上,我显示了一个 PDF 文件作为页面内容。

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).我需要一种方法来知道我可以制作 PDF 控件的大小,这样我就不会为网页创建滚动条(PDF 控件有它自己的滚动条)。

I was able to solve this horizontally by setting the width of the control to 100%.我能够通过将控件的宽度设置为 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.无法确定此服务器端,因此您需要使用 JavaScript。 I'd recommend the jQuery Dimensions plug in .我推荐jQuery Dimensions 插件

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.但是,如果您确实使用 JavaScript,则有一种解决方法,您可以将该值放入 HiddenField(当然 JavaScript 会将其视为输入),然后单击“提交”按钮,所有这些都在幕后进行。 If you use an UpdatePanel, you may be able to get away with a partial postback without user intervention.如果您使用 UpdatePanel,您可能能够在没有用户干预的情况下进行部分回发。

For the button clickery, look into Document.Forms[0].btnMyButton.Click();.对于按钮 clickery,请查看 Document.Forms[0].btnMyButton.Click();。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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