第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

刷新頁(yè)面并保持滾動(dòng)位置

刷新頁(yè)面并保持滾動(dòng)位置

有只小跳蛙 2019-10-19 15:55:32
有人可以告訴我我在做什么錯(cuò)嗎?我需要在一段時(shí)間后刷新頁(yè)面,但它會(huì)刷新到頁(yè)面頂部,我需要不更改頁(yè)面位置!所以這是我現(xiàn)在無(wú)法使用的,是meta標(biāo)簽嗎?這是我所沒有的仍然不刷新必須做錯(cuò)了什么嗎?這是我本來(lái)的...<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>    <head>        <meta http-equiv="refresh" content="72">        <meta http-equiv="Pragma" CONTENT="no-cache">        <meta http-equiv="Expires" CONTENT="-1">        <style type="text/css">        body        {             background-image: url('../Images/Black-BackGround.gif');            background-repeat: repeat;        }        </style>    </head>    <script type="text/javascript">    function saveScrollPositions(theForm) {        if(theForm) {            var scrolly = typeof window.pageYOffset != 'undefined' ? window.pageYOffset                                                   : document.documentElement.scrollTop;            var scrollx = typeof window.pageXOffset != 'undefined' ? window.pageXOffset                                                  : document.documentElement.scrollLeft;            theForm.scrollx.value = scrollx;            theForm.scrolly.value = scrolly;        }    }    </script> <form action="enroll.php" name="enrollment" method="post" onsubmit="return saveScrollPositions (this);">  <input type="hidden" name="scrollx" id="scrollx" value="0" />  <input type="hidden" name="scrolly" id="scrolly" value="0" />  <STYLE type="text/css">   #Nav a{ position:relative; display:block; text-decoration: none; color:Black; }   Body td{font-Family: Arial; font-size: 12px; }  </style>閱讀了一些初始答案后,我將其更改為...<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><style type="text/css">body{     background-image: url('../Images/Black-BackGround.gif');    background-repeat: repeat;}</style></head><script>function refreshPage () {    var page_y = $( document ).scrollTop();    window.location.href = window.location.href + '?page_y=' + page_y;}
查看完整描述

3 回答

?
慕雪6442864

TA貢獻(xiàn)1812條經(jīng)驗(yàn) 獲得超5個(gè)贊

更新


您可以使用document.location.reload(true)下面提到的方法代替下面的強(qiáng)制技巧。


將HTML替換為:


<!DOCTYPE html>

<html>

    <head>

        <style type="text/css">

            body { 

                background-image: url('../Images/Black-BackGround.gif');

                background-repeat: repeat;

            }

            body td {

               font-Family: Arial; 

               font-size: 12px; 

            }

            #Nav a { 

                position:relative; 

                display:block; 

                text-decoration: none; 

                color:black; 

            }

        </style>

        <script type="text/javascript">

            function refreshPage () {

                var page_y = document.getElementsByTagName("body")[0].scrollTop;

                window.location.href = window.location.href.split('?')[0] + '?page_y=' + page_y;

            }

            window.onload = function () {

                setTimeout(refreshPage, 35000);

                if ( window.location.href.indexOf('page_y') != -1 ) {

                    var match = window.location.href.split('?')[1].split("&")[0].split("=");

                    document.getElementsByTagName("body")[0].scrollTop = match[1];

                }

            }

        </script>

    </head>

    <body><!-- BODY CONTENT HERE --></body>

</html>


查看完整回答
反對(duì) 回復(fù) 2019-10-19
?
猛跑小豬

TA貢獻(xiàn)1858條經(jīng)驗(yàn) 獲得超8個(gè)贊

document.location.reload()存儲(chǔ)位置,請(qǐng)參閱docs。


添加其他true參數(shù)以強(qiáng)制重新加載,但不恢復(fù)位置。


document.location.reload(true)

MDN文檔:


forceReload標(biāo)志更改了某些瀏覽器處理用戶滾動(dòng)位置的方式。通常reload()之后會(huì)恢復(fù)滾動(dòng)位置,但是強(qiáng)制模式可以滾動(dòng)回到頁(yè)面頂部,就像window.scrollY === 0一樣。


查看完整回答
反對(duì) 回復(fù) 2019-10-19
?
侃侃爾雅

TA貢獻(xiàn)1801條經(jīng)驗(yàn) 獲得超16個(gè)贊

如果您不想使用本地存儲(chǔ),則可以將頁(yè)面的y位置附加到url上,并在加載時(shí)使用js進(jìn)行抓取,并將頁(yè)面偏移量設(shè)置為傳入的get參數(shù),即:


//code to refresh the page

var page_y = $( document ).scrollTop();

window.location.href = window.location.href + '?page_y=' + page_y;



//code to handle setting page offset on load

$(function() {

    if ( window.location.href.indexOf( 'page_y' ) != -1 ) {

        //gets the number from end of url

        var match = window.location.href.split('?')[1].match( /\d+$/ );

        var page_y = match[0];


        //sets the page offset 

        $( 'html, body' ).scrollTop( page_y );

    }

});


查看完整回答
反對(duì) 回復(fù) 2019-10-19
  • 3 回答
  • 0 關(guān)注
  • 805 瀏覽

相關(guān)問(wèn)題推薦

慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)