小编fre*_*k99的帖子

找到页面的最大滚动位置

我已经使页面的主体高200%,以便它适合屏幕两次.使用javascript我滚动时会一直滚动到顶部或底部.为此,我需要在任何浏览器或屏幕大小上找到页面的最低滚动点,以便在它到达时停止.

请不要JQuery.
谢谢.

我的代码:(它仍然被放在一起所以需要一些工作)

function getScrollXY() {
    var x = 0, y = 0;
    if( typeof( window.pageYOffset ) == 'number' ) {
        // Netscape
        x = window.pageXOffset;
        y = window.pageYOffset;
    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        // DOM
        x = document.body.scrollLeft;
        y = document.body.scrollTop;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        // IE6 standards compliant mode
        x = document.documentElement.scrollLeft;
        y = document.documentElement.scrollTop;
    }
    return [x, y];
}

function scrollup() …
Run Code Online (Sandbox Code Playgroud)

javascript scroll

15
推荐指数
3
解决办法
3万
查看次数

传递'printf'的参数1使得指针来自整数

我一直收到这个错误

box2.c: In function 'printchars':
box2.c:26:4: warning: passing argument 1 of 'printf' makes pointer from integer without  a      
cast [enabled by default]
/usr/include/stdio.h:363:12: note: expected 'const char * __restrict__' but argument is      
of type 'char' box2.c:26:4: warning: format not a string literal and no format arguments [-Wformat-security]
box2.c:39:8: warning: passing argument 1 of 'printf' makes pointer from integer without      a cast [enabled by default]
/usr/include/stdio.h:363:12: note: expected 'const char * __restrict__' but argument is     of type 'char'
box2.c:39:8: warning: format …
Run Code Online (Sandbox Code Playgroud)

c arguments

4
推荐指数
1
解决办法
3万
查看次数

如何在循环内交换 Vec 的两个索引的内容?

我正在尝试交换循环内的元素。

fn foo(nums: &mut Vec<i32>) {
  let mut i: usize = 0;
  for (j, n) in nums.iter_mut().enumerate() {
    if n != &0 {
      // swap nums[i] and nums[j];
      i = i + 1;
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

但我不断收到相同的错误(同时不能多次借用可变 nums)。我究竟做错了什么?

rust

2
推荐指数
1
解决办法
95
查看次数

标签 统计

arguments ×1

c ×1

javascript ×1

rust ×1

scroll ×1