Here is my codes:
Javascript:
document.body.onload = function() {
function UP() {//Ẩn hiện nút UP
if(window.pageYOffset > window.innerHeight)
document.getElementById('UP').style.display = block;
}
}
HTML tag:
<button id=UP onclick=toTop(350);></button>
CSS style:
#UP {display: none;}
My idea is when I scroll down, then UP button will appear. But don't know why, it won't, it even return the error: Uncaught TypeError: Cannot set property 'document.body' of null. Of couse, I did change other script like this:
function getReady() {
UP();
}
function UP() {//Ẩn hiện nút UP
if(window.pageYOffset > window.innerHeight)
document.getElementById('UP').style.display = block;
}
HTML tag:
<body onload=getReady();>
<button id=UP onclick=toTop(350);></button>
</body>
It is even more terrible. When I load site, I didn't see onload attr of body tag and the browser didn't return any error for me.
Some other infomation:
I develop on both side, Cr & FF, it all says a same problem.
And I'm working on Wordpress source.