Sharepoint窗口滚动未触发

Evg*_*vin 6 html javascript sharepoint jquery scroll

我有我的SharePoint页面生成的HTML(剪辑):

<body scroll="yes" onload="if (typeof(_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper();" class="v4master" style="overflow: scroll" spellcheck="false">
    <form name="aspnetForm" method="post" action="/Lists/List/EditNewForm.aspx?ID=2&amp;Source=https%3A%2F%2Fsp2010-test%2Eatwss%2Ecom%2FLists%2FList%2FAllItems%2Easpx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm" style="overflow: scroll">

// some html here

<div id="competenceTotalSum" style="position: absolute; left: 500px; top: 400px; width: 100px; height: 50px; background-color:gray" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
    $(function(){       
        $("form#aspnetForm").bind("scroll", function(e){
            alert("scroll");
            $("#competenceTotalSum").css("top", $(this).scrollTop() + 400);
        });
    });
</script>

// some html here

    </form>
</body>
Run Code Online (Sandbox Code Playgroud)

事件scroll没有解雇.我改变scroll的属性body,溢出特性bodyform,试图结合scroll事件,以不同的对象(window,body,form).将scroll事件更改为click事件时 - 它会触发.除了overflow滚动元素的属性之外,我没有找到任何理由.

Anj*_*... 20

这是一个古老的问题但仍然可能对其他人有帮助,我想在我的一个共享点项目中实现滚动到顶部功能.

几个小时左右我的头后.我得到了以下代码.

实际上$(window).scroll()不会在共享点开火,我使用那里的主人ID,这是('#s4-workspace')为了让它工作.

$(document).ready(function () {
    var offset = 220;
    var duration = 1000;

  jQuery('#s4-workspace').scroll(function() {

        if (jQuery(this).scrollTop() > offset) {
            jQuery('.arrowToTop').fadeIn(duration);
        } else {
            jQuery('.arrowToTop').fadeOut(duration);
        }
    });

    jQuery('.arrowToTop a').click(function(event) {
        event.preventDefault();
       jQuery('#s4-workspace').animate({scrollTop: 0}, duration);
        return false;
    }) });
Run Code Online (Sandbox Code Playgroud)

我使用了下面的CSS样式

.arrowToTop {
   display: none;
   height: 100%;
   position: fixed;
   right: 20px;    
   z-index: 9999;
   bottom: 0;
   width: 70px;
   height:70px;
} 

.arrowToTop a{     
    width: 70px;
    height:70px; 
    display: block;
     background: url(../images/arrow.png) no-repeat left 0;
    }
Run Code Online (Sandbox Code Playgroud)

  • 哇,最后一个有效的版本..非常感谢你:D (2认同)