Results 1 to 3 of 3

Thread: Identify Window focus event in android , iphone

  1. #1
    Sencha User tomalex0's Avatar
    Join Date
    Apr 2009
    Location
    San Jose, CA
    Posts
    589
    Answers
    1

    Default Identify Window focus event in android , iphone

    Is there any event which is triggered when a window is focused by tab change or accessed from background? Let's say our page is accessed from browser(ios,android) and then browser is minimized or another tab is selected . So when we get back to our page tab or open browser from backgorund some event should fire .

    I tried it separately and looks to work fine in IOS5.1 (haven't tried others). Regarding android same behavior is not happening. Please check the code below.

    Code:
    <!DOCTYPE html> 
       <html> 
       <head>
          <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no,,minimum-scale=1.0, maximum-scale=1.0">
          <meta name="apple-mobile-web-app-capable" content="yes" />
          <title>Event</title> 
           
          <script>
             
              loadevents = ['focus','readystate','readystatechange', 'pageshow', 'pagehide'];
              triggeredEvents = [];
              function lognamed(name) {
                  window.addEventListener(name, function () {
                      console.log(name);
                     
                      triggeredEvents.push(name);
    
    
                      if (name == "pageshow" || name == "focus") {
                          var indexpos = triggeredEvents.indexOf('readystatechange');
                          console.log(indexpos + "--position");
                          triggeredEvents = [];
                          if (indexpos < 0) {
                              triggeredEvents = [];
                              //window.location.reload();
                          }
                      }
    
    
                  }, true);
               }
    
    
               loadevents.forEach(function (name) {
                    lognamed(name); 
               });
             
              
          </script>
       </head> 
    <body>
           
    </body>
    </html>
    Sencha Touch Demos

    IosToggleField Forum - Github
    Form Validation
    Forum - Github
    Iphone Settings Menu
    Forum
    Sqlite Storage & Login Manifest
    Forum
    KitchenSink MVC
    Forum - Github
    SqliteProxy-v1 Forum - Github
    SqliteProxy-v2
    Forum - Github
    Arshaw Fullcalendar Forum - Github






  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    If supported, the focus event should do the job you want.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    1

    Default

    Hi da,

    Did you get any solution for this?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •