User:TheProgrammedDev/vector.js

var tDiv = document.createElement("div"); tDiv.id = "tDiv"; var tPer = document.createElement("div"); tPer.id = "tPer";

var tPer2 = document.createElement("div"); tPer2.id = "tPer2";

tDiv.appendChild(tPer2); tDiv.appendChild(tPer);

document.body.appendChild(tDiv); window.onscroll = function{ //alert("a"); var body = document.body, html = document.documentElement; var height = document.documentElement.scrollHeight; //alert(document.documentElement.scrollTop, height); //alert(window.innerHeight); var percnt = document.documentElement.scrollTop/Math.abs(height-window.innerHeight)*100; var string = "calc(" + percnt + "% + 10px)"; if (percnt == 0) { string = "0px"; } tDiv.style.width = string; tPer.innerHTML = Math.floor(percnt) + "%"; tPer2.innerHTML = Math.floor(percnt) + "%"; };