Click here to Skip to main content
15,897,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
blink a minimized webpage like in gmail chat when new message received. I am showing an ajax model popup from a jquery function. i want to if browser is minimized then user get notified by blinking the minimized browser.

What I have tried:

<asp:LinkButton ID="lnkFake" runat="server" />
                       <asp:ModalPopupExtender ID="mpeTimeout" BehaviorID="mpeTimeout" runat="server" PopupControlID="pnlPopup"
                           TargetControlID="lnkFake" OkControlID="btnYes"  BackgroundCssClass="modalBackground"
                           OnOkScript="ResetSession()">
                       </asp:ModalPopupExtender>
                       <asp:Panel ID="pnlPopup" runat="server" CssClass="modalPopup" Style="display: none">
                           <div class="header">
                               Session Expiring!
                           </div>
                           <div class="body">
                               Your Session will expire in <span id="seconds"></span> seconds.<br />
                               Do you want to reset?
                           </div>
                           <div class="btnSection" align="right">
                               <asp:Button ID="btnYes" runat="server" Text="OK" CssClass="yes" />
                              <%-- <asp:Button ID="btnNo" runat="server" Text="No" CssClass="no" />--%>
                           </div>
                       </asp:Panel>




<script type="text/javascript">
                            var myTimer;
                            var myTimer2;
                            var myTimer3;
                            function SessionExpireAlert(timeout) {
                               
                                var seconds = timeout / 1000;
                               // document.getElementsByName("secondsIdle").innerHTML = seconds;
                                document.getElementsByName("seconds").innerHTML = seconds;
                                myTimer = setInterval(function () {
                                    seconds--;
                                    document.getElementById("seconds").innerHTML = seconds;
                                 //   document.getElementById("secondsIdle").innerHTML = seconds;
                                }, 1000);
                                myTimer2=setTimeout(function () {
                                    //Show Popup before 20 seconds of timeout.
                                   // alert('hi');
                              
                                    $find("mpeTimeout").show();
                                }, timeout - 60 * 1000);
                                myTimer3 = setTimeout(function () {
                                    //alert(" Your Session has expired.");
                                    window.location = '<%=ResolveUrl("~/CRM/Login.aspx") %>';
                                   // window.location = "Expired.aspx";
                                }, timeout);
                            };
                            function ResetSession() {
                                //Redirect to refresh Session.
                                //window.location = window.location.href;
                                $.ajax({
                                    type: "POST",
                                    contentType: "application/json; charset=utf-8",
                                    url: '<%=ResolveUrl("~/CRM/Login.aspx/ResetSession") %>',
                                    dataType: "json",
                                    success: function (data) {
                                        clearInterval(myTimer);
                                        clearInterval(myTimer2);
                                        clearInterval(myTimer3);
                                        SessionExpireAlert(data.d);
                                    },
                                    error: function (result) {
                                        alert("Error");
                                    }
                                });
                            }
                        </script>
Posted
Updated 12-Apr-17 1:10am

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