asp.net – MaintainScrollPositionOnPostback属性不适用于mozilla

前端之家收集整理的这篇文章主要介绍了asp.net – MaintainScrollPositionOnPostback属性不适用于mozilla前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
MaintainScrollPositionOnPostback = true

它与IE合作但不与mozilla合作(版本9)

建议另一种保持与浏览器无关的滚动位置的方法..

thanxx

解决方法

在这里找到答案:

http://weblogs.asp.net/andrewfrederick/archive/2008/03/04/maintain-scroll-position-after-asynchronous-postback.aspx

和这里:

http://www.4guysfromrolla.com/articles/111704-1.aspx

如果它适合您,请告诉我!

编辑

由于我只是链接答案,我实际上只是粘贴代码片段,以防这些链接消失:

http://weblogs.asp.net/andrewfrederick/archive/2008/03/04/maintain-scroll-position-after-asynchronous-postback.aspx开始:

<script type="text/javascript">
    var xPos,yPos;
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_beginRequest(BeginRequestHandler);
    prm.add_endRequest(EndRequestHandler);
    function BeginRequestHandler(sender,args) {
        xPos = $get('scrollDiv').scrollLeft;
        yPos = $get('scrollDiv').scrollTop;
    }
    function EndRequestHandler(sender,args) {
        $get('scrollDiv').scrollLeft = xPos;
        $get('scrollDiv').scrollTop = yPos;
    }
</script>

来自:http://www.4guysfromrolla.com/articles/111704-1.aspx

<script language = "javascript">

    function sstchur_SmartScroller_GetCoords()
    {
        var scrollX,scrollY;

        if (document.all)
        {
            if (!document.documentElement.scrollLeft)
                scrollX = document.body.scrollLeft;
            else
                scrollX = document.documentElement.scrollLeft;

            if (!document.documentElement.scrollTop)
                scrollY = document.body.scrollTop;
            else
                scrollY = document.documentElement.scrollTop;
        }   
        else
        {
            scrollX = window.pageXOffset;
            scrollY = window.pageYOffset;
        }

        document.forms[formID].xCoordHolder.value = scrollX;
        document.forms[formID].yCoordHolder.value = scrollY;
    }

    function sstchur_SmartScroller_Scroll()
    {
        var x = document.forms[formID].xCoordHolder.value;
        var y = document.formsformID].yCoordHolder.value;
        window.scrollTo(x,y);
    }

    window.onload = sstchur_SmartScroller_Scroll;
    window.onscroll = sstchur_SmartScroller_GetCoords;
    window.onkeypress = sstchur_SmartScroller_GetCoords;
    window.onclick = sstchur_SmartScroller_GetCoords;

<script>

对于那些努力解决这些问题的人来说,这些都归功于他们.

原文链接:https://www.f2er.com/aspnet/251580.html

猜你在找的asp.Net相关文章