Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
XML
// alternative to DOMContentLoaded
        document.onreadystatechange = function () {
            if (document.readyState == "complete") {
                //lastAddedLiveFunc();
            }
        }
        window.onscroll = function () {
            var wintop = getScrollY(), docheight = document.body.clientHeight, winheight = document.documentElement.clientHeight;
//            document.getElementById("scrollTop").value = wintop;
//            document.getElementById("docheight").value = docheight;
//            document.getElementById("winheight").value = winheight;
            //scroll base
            var scrolltrigger = 0.95;
            if ((wintop / (docheight - winheight)) > scrolltrigger) { ntAjax.lastAddedLiveFunc(); }
        }
        window.getScrollY = function () {
            var scrOfY = 0;
            if (typeof (window.pageYOffset) == 'number') {
                //Netscape compliant
                scrOfY = window.pageYOffset;
            } else if (document.body && document.body.scrollTop) {
                //DOM compliant
                scrOfY = document.body.scrollTop;
            } else if (document.documentElement && document.documentElement.scrollTop) {
                //IE6 standards compliant mode
                scrOfY = document.documentElement.scrollTop;
            }
            return scrOfY;
        }
        var ntAjax = {
            lastAddedLiveFunc: function () {
                var oReq = this.getXMLHttpRequest();
                if (oReq != null) {
                    document.getElementById("lastPostsLoader").innerHTML = '<img src="http://www.jquery4u.com/demos/infinite-scrolling-demo5/bigLoader.gif">';
                    oReq.onreadystatechange = this.reqListener;
                    oReq.open("get", "contentpage.aspx", true);
                    oReq.send();
                }
            },
            reqListener: function () {
                //complete
                if (this.readyState == 4) {
                    if (this.status == 200) {
                        var data = this.responseText;
                        var bsa = document.createElement('li');
                        bsa.innerHTML = data;
                        document.getElementById("ulItems").insertBefore(bsa, document.getElementById("ulItems").lastChild)
                        document.getElementById('lastPostsLoader').innerHTML = '';
                    }
                }
            },
            getXMLHttpRequest: function () {
                if (window.XMLHttpRequest) { return new window.XMLHttpRequest; }
                else {
                    try { return new ActiveXObject("Microsoft.XMLHTTP"); }
                    catch (ex) { return null; }
                }
            }
        };


        <ul id="ul1" class="items">
            <li>
                <h4 class="itemtitle">
                    Header
                </h4>
                <div class="itemcontent" name="decodeable">
                    Text</div>
            </li>
            <li>
                <h4 class="itemtitle">
                    Header
                </h4>
                <div class="itemcontent" name="decodeable">
                    Text</div>
            </li>
        </ul>
        <div id="lastPostsLoader">
        </div>
Posted
Updated 25-Sep-13 6:57am
v2

1 solution

What is the issue ?

Javascript depends of the browser used for test and the doctype of the page.

here a link to a compatibility page : http://kangax.github.io/es5-compat-table/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900