将浏览器大小更改为特定的高度/宽度?
由于用户似乎没有办法在不使用某种插件的情况下截取网页的屏幕截图,我想我至少会迎合插件。例如,Firefox 的 Pagesaver 允许我仅保存正在查看的网站的可见部分。为了满足这一点,我想开发一个脚本,将窗口大小更改为相关父 div 的边界,或更改为静态宽度/高度。
例如,我有一个具有静态宽度和侧面 WS 的网站。我想要一个按钮,当单击该按钮时,将窗口的宽度更改为中心列的宽度,以便不显示 WS。 (如果页面不是全高,高度也是如此)这样,如果他们有像页面保护程序这样的插件,他们就不会保存网站的无用部分。
这可能吗?它不一定是一个新窗口,调整当前窗口的大小可能会减少工作/首选。我知道广告总是对我这样做,所以这一定是可能的......
Since there doesn't seem to be a way for a user to take a screenshot of a webpage without using some sort of plugin, i figured i'd at least cater to the plug-ins. For example, Pagesaver, for firefox, lets me save just the visible portion of the website i'm viewing. To cater to this, i'd like to develop a script that changes my window size to the boundaries of a relevant parent div, or to a static width/height.
For example, i have a site with a static width and WS on the sides. I'd like to have a button that when clicked, changes the window's width to the width of the center column, so that no WS shows. (same goes for height if the page isn't full height) This way, if they have a plug-in like pagesaver, they aren't saving useless portions of the site.
Is this possible? It doesn't necessarily have to be a new window, resizing the current window would probably be less work/preferred. I know ads do this to me all the time, so it must be possible...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
调整窗口大小很容易,但我认为调整窗口大小以仅显示您想要的内容(自动)更复杂。一个简单的解决方案是在单独的页面中加载所需的 div,在 div 上使用 jQuery
width()
和height()
函数,然后window.resizeTo(宽度,高度)
。值得一试。Resizing the window is easy, but I think resizing it to just show the content you want (automatically) is more involved. An easy solution would be to load just the div you want in a separate page, use the jQuery
width()
andheight()
functions on the div, and thenwindow.resizeTo(width, height)
. Worth a try.快速 Google 搜索会发现:http://members.iinet.net.au/ ~rkb/tips_HTML_window_size.htm
只需调用
window.resizeTo(newWidth, newHeight)
。A quick Google search turns up this: http://members.iinet.net.au/~rkb/tips_HTML_window_size.htm
Just call
window.resizeTo(newWidth, newHeight)
.