简体   繁体   English

缩放网页,然后单击“后退”按钮更改上一页的背景大小

[英]Zooming webpage then clicking back button changes the background size on the previous page

I have two webpages that consist of a scrollable div as the main wrapper and an image background styled like 我有两个网页,其中包含一个可滚动的div作为主要包装器,以及一个图像背景,其样式类似于

body
{
background: url("../Images/background.jpg") center bottom no-repeat;
z-index:-5; 
background-size:cover;
}

When I zoom in or out, the scrollable div changes sizes and the background does not. 当我放大或缩小时,可滚动的div会更改大小,而背景不会更改。 That is exactly what I want to happen. 这正是我想要发生的事情。

However, if I zoom in on one page then click the browser's back button, the background is zoomed out on the previous page. 但是,如果我放大一页,然后单击浏览器的“后退”按钮,则背景将在前一页上缩小。 If I refresh the page the background is fixed and everything is displayed correctly again. 如果刷新页面,背景将固定,并且一切都将正确显示。 If I zoom then click a link to the previous page instead of clicking back in the browser window, the page is displayed correctly. 如果我缩放然后单击指向上一页的链接,而不是在浏览器窗口中单击回来,则该页面将正确显示。 I have tried using the hidden field 我尝试使用隐藏字段

<input type="hidden" id="refresh" value="no"/>

with the following script 使用以下脚本

<script type="text/javascript">
$(window).load(function (e) {
    var $input = $('#refresh');

    $input.val() == 'yes' ? location.reload(true) : $input.val('yes');
});
</script>

to reload the page one time after its initial load hoping that the background would resize, but it does not. 在初始加载一次后重新加载页面,希望背景会调整大小,但不会。 only clicking the browser refresh button will fix it. 仅单击浏览器刷新按钮即可修复它。 Any suggestions as to how to handle this would be extremely helpful. 关于如何处理此问题的任何建议将非常有帮助。

使用$(window).resize()评分器而不是$(window).load()`,如果问题出在缩放或调整大小上可能会有所帮助

暂无
暂无

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

相关问题 通过单击后退按钮重新加载上一页 - Reload the previous page by clicking the back button 不允许将CSS携带到上一页(单击浏览器后退按钮后) - Not allowing CSS to be carried to previous page (after clicking browser back button) 单击浏览器的“后退”按钮时,返回上一页的上一个位置 - Go Back to the Previous Location on Previous Page when Clicking Browser Back Button 即使更改了哈希值,如何在网页中单击浏览器后退按钮时返回上一页? - How to go back to the previous page when browser back button is clicked in a webpage even when the hash is changed? 单击浏览器后退按钮时,将用户带回上一页滚动到的位置 - Take User Back to Where They Scrolled to on previous page when clicking Browser Back Button 如何通过在javascript中单击浏览器的后退按钮将页面恢复到之前的状态 - How to take back a page to its previous state by clicking the back button of the browser in javascript 页面重定向后单击浏览器后退按钮后上一页未加载 - Previous page not loading after clicking browser back button after a page redirection 单击浏览器后退按钮时如何转到当前页面的上一页 - How to go previous page of current page , while clicking browser back button 用户单击上一页的后退按钮后如何重新加载网页? - How to reload a webpage after user clicks back button from previous page? 检票口:后退按钮上一页 - wicket: back button previous page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM