Showing posts with label JQuery. Show all posts
Showing posts with label JQuery. Show all posts

Wednesday, February 1, 2017

Prevent safari loading from cache when back button is clicked

Your problem is caused by back-forward cache. It is supposed to save complete state of page when user navigates away. When user navigates back with back button page can be loaded from cache very quickly. This is different from normal cache which only caches HTML code.

When page is loaded for bfcache onload event wont be triggered. Instead you can check the persisted property of the onpageshow event. It is set to false on initial page load. When page is loaded from bfcache it is set to true.

Kludgish solution is to force a reload when page is loaded from bfcache.

window.onpageshow = function(event) {
    if (event.persisted) {
        window.location.reload()
    }
};

If you are using jQuery then do:

$(window).bind("pageshow", function(event) {
    if (event.originalEvent.persisted) {
        window.location.reload()
    }
});

Wednesday, May 11, 2016

JQuery data table



<link href="~/Content/dataTable/cdn.datatables.net/1.10.9/css/dataTables.bootstrap.min.css" rel="stylesheet" />
<script src="~/Content/dataTable/datatables.net/media/js/site329d.js"></script>
<script src="~/Content/dataTable/code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="~/Content/dataTable/cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
<script src="~/Content/dataTable/cdn.datatables.net/1.10.9/js/dataTables.bootstrap.min.js"></script>



<script type="text/javascript">
    $j = jQuery.noConflict();
    $j(document).ready(function () {
        //For data table
        $j('#example').DataTable({
            "iDisplayLength": 25,   // default load data
            "order": [[4, "desc"]],  // Default desc order
            stateSave: true,   // Maintain the paging session to next page
            // "bProcessing": true,
            // "bSort": false
            "aoColumnDefs": [{ 'bSortable': false, 'aTargets': [5] }]  // hide the column

        });
    });
</script>

Thursday, December 27, 2012

Reload JQuery


    function pageLoad(sender, args) {
        if (args.get_isPartialLoad()) {
            $jc(function() {
                $jc(".newsticker-jcarousellite").jCarouselLite({
                    vertical: true,
                    hoverPause: true,
                    visible: 10,
                    auto: 500,
                    speed: 3000
                });
            });
        }
    }

Tuesday, October 9, 2012

get Scrolling Event.


<script src="JS/jquery-1.7.1.js" type="text/javascript"></script>

<script type="text/javascript">
    $(document).ready(function() {
        var ROOT = (function() {
            var html = document.documentElement;
            var htmlScrollTop = html.scrollTop++;
            var root = html.scrollTop == htmlScrollTop + 1 ? html : document.body;
            html.scrollTop = htmlScrollTop;
            return root;

        })();

        // may be recalculated on resize
        var limit = (document.body.scrollHeight - $(window).height()) * 0.85;
        var visible = false;
        var last = +new Date;
        var didScroll = false;

        $(window).scroll(function() {
            didScroll = true;

        })

        setInterval(function() {
            if (didScroll) {
                didScroll = false;
                if (visible && ROOT.scrollTop < limit) {
                    hideCredit();
                    visible = false;
                } else if (!visible && ROOT.scrollTop > limit) {
                    showCredit();
                    visible = true;
                }
            }
        }, 30);


        function hideCredit() {
            console.log('The hideCredit function has been called.');
            alert("hide");

        }

        function showCredit() {
            console.log('The showCredit function has been called.');
            alert("show");

        }
    });

</script>