Monday 26 March 2012

Display Popup for some time & auto hide that popup after specified time...

If Not Session("IsimgAddToCart") Is Nothing Then 'Added by Team7e for Popup Issue.
                If Session("IsimgAddToCart") = "yes" Then
               ScriptManager.RegisterClientScriptBlock(Page, Me.GetType(), "MyScript", "startPopup()", True)
                    Session("IsimgAddToCart") = "no"
                Else
                    Session("IsimgAddToCart") = "no"
                End If
            End If
=======================================================

<%--This is for popup Issue.--%>
   <script type='text/javascript'>
        function closeMyPopup() {
            document.getElementById("ctl00_pnlviewcart").style.display = "none";
        }

        function myPopupRelocate() {
            var scrolledX, scrolledY;
            if (self.pageYOffset) {
                scrolledX = self.pageXOffset;
                scrolledY = self.pageYOffset;
            } else if (document.documentElement && document.documentElement.scrollTop) {
                scrolledX = document.documentElement.scrollLeft;
                scrolledY = document.documentElement.scrollTop;
            } else if (document.body) {
                scrolledX = document.body.scrollLeft;
                scrolledY = document.body.scrollTop;
            }

            var centerX, centerY;
            if (self.innerHeight) {
                centerX = self.innerWidth;
                centerY = self.innerHeight;
            } else if (document.documentElement && document.documentElement.clientHeight) {
                centerX = document.documentElement.clientWidth;
                centerY = document.documentElement.clientHeight;
            } else if (document.body) {
                centerX = document.body.clientWidth;
                centerY = document.body.clientHeight;
            }

            var leftOffset = scrolledX + (centerX - 250) / 2;
            var topOffset = scrolledY + (centerY - 200) / 2;

            document.getElementById("ctl00_pnlviewcart").style.top = topOffset + "px";
            document.getElementById("ctl00_pnlviewcart").style.left = leftOffset + "px";
        }
        function startPopup() {
                window.setTimeout("fireMyPopup()", 500);
        }
        function fireMyPopup() {
            myPopupRelocate();
            document.getElementById("ctl00_pnlviewcart").style.display = "block";
            document.body.onscroll = myPopupRelocate;
            window.onscroll = myPopupRelocate;
            window.setTimeout("closeMyPopup()", 5000);
        }
//        document.body.onload = window.setTimeout("fireMyPopup()", 500);
    </script>

No comments:

Post a Comment