你好,直接用document.write会使页面直接变成空白……
而考虑到你的unescape()是返回的文本值,用原生的JS不方便解析成节点,所以也不好用append()方法追加新内容。
但是,咱还有万能的innerHTML属性哦~~请看示例代码,一行即解决:
document.body.innerHTML += unescape("这里的内容会被添加到页面底部~")我已经调试通过了。
如果对此还有疑惑,欢迎追问~
js判断window.scroll 判断滚动到底部的方法是设置一个变量,来检测鼠标位置。具体的实现方法如下:
$(window).scroll(function() {
如果滚动的高度加上窗口的高度等于页面的高度就是到了底部
if($(window).scrollTop() + $(window).height() == $(document).height()) {
alert("bottom!")//已经滚动到底部
}
})
或者也可以写专用方法检测高度:
function getDocHeight() {
var D = document
return Math.max(
D.body.scrollHeight, D.documentElement.scrollHeight,
D.body.offsetHeight, D.documentElement.offsetHeight,
D.body.clientHeight, D.documentElement.clientHeight
)
}
然后再用以下方法检测:
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == getDocHeight()) {
alert("bottom!")
}
})