123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- Namespace.register("U.Rolling.load"); //命名空间 14互联网1 刘希鹏
- /*window.onload = function () {
- //U.Rolling.Create();
- //U.Rolling.load();
- }*/
- window.onload = function () { }
- U.Rolling.load.Create = function () {
- //创建div容器
- var over = $$("div", { "class": "U_Rolling_over" }, $("body")[0]);
- var testa = $$("div", { "class": "U_Rolling_testa" }, over);
- var wrap = $$("div", { "id": "U_Rolling_wrap", "class": "U_Rolling_wrap" }, testa);
- for (var i = 0; i < 6; i++) { //打印实际数据
- var main = $$("div", { "class": "U_Rolling_main" }, wrap);
- var test = $$("div", { "class": "U_Rolling_test" }, main);
- test.innerText = i;
- }
- var b = $("#U_Rolling_wrap")[0];
- b.onscroll = function () { U.Rolling.load.start(b); }
- return over;
- }
- U.Rolling.load.start = function (str) { //参数str1 获取滚动距离的div, str2表示获取全文高度的div
- //alert(str1);
- //获取滚动条的滚动的距离
- getScrollTop = function () {
- /*var scrollTop = 0;
- if (document.body) {
- !--scrollTop = document.body.scrollTop;
- }*/
- return str.scrollTop;
- };
- //获取屏幕的可见范围
- getClientHeight = function () {
- return str.clientHeight;
- };
- //获取全文的高度
- getScrollHeight = function () {
- return str.scrollHeight;
- };
- //滚动条+可视范围=完整高度
- if (getScrollTop() + getClientHeight() >= getScrollHeight()) {
- //var a = document.getElementById("wrap");
- //a.scrollTop+=25;
- //var loding = $$("div",{"id":"loding","style":"background:red;width:100%;height:25px;"},$("#wrap")[0]);
- //alert(1)
- if (document.getElementById('UCD_CT_SM_IF').contentWindow.document.getElementById('U_Rolling_txt') == undefined) { //判断这个loding的gif是否存在 不加这个限制的话 用户可以一直创建loding的gif
- var main = $$("div", { "class": "U_Rolling_main" }, str);
- var test = $$("div", { "id": "U_Rolling_txt", "class": "U_Rolling_testb" }, main);
- str.scrollTop += 150;
- var txt = setInterval(function () { //3秒后消失 有了实际的数据就不用这个计时器的 数据获取到后 就可以把gif remove掉
- document.getElementById('UCD_CT_SM_IF').contentWindow.document.getElementById('U_Rolling_txt').remove(); //gif remove
- clearInterval(txt);
- for (var i = 0; i < 6; i++) { //打印实际数据
- var main = $$("div", { "class": "U_Rolling_main" }, str);
- var test = $$("div", { "class": "U_Rolling_test" }, main);
- test.innerText = i;
- }
- }, 3000)
- } else { return; }
- }
- };
|