Skip to content

Isn`t working and tried a long time #8

Description

@tcruise52

Hey there,
Hope anybody can help me. I made a web-app with jquery mobile and I have three pages. index.php, login.php and logout.php. When I login and click I link I jump out of the webapp to safari. So I used this code but doensn`t work.
Hope anybody can help me.

My Codes:


<script src="js/jquery.stayInWebApp.js"></script> <script type="text/javascript" src="./jquery-1.7.1.min.js"></script> <script src="http://code.jquery.com/jquery-1.11.2.min.js"></script> <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

And this one in /js:
/*!

  • jQuery stayInWebApp Plugin
  • version: 0.4 (2012-06-19)
    */

;(function($) {
//extend the jQuery object, adding $.stayInWebApp() as a function
$.extend({
stayInWebApp: function(selector) {
//detect iOS full screen mode
if(("standalone" in window.navigator) && window.navigator.standalone) {
//if the selector is empty, default to all links
if(!selector) {
selector = 'a';
}
//bind to the click event of all specified elements
$("body").delegate(selector,"click",function(event) {
//TODO: execute all other events if this element has more bound events
/* NEEDS TESTING
for(i = 0; i < $(this).data('events'); i++) {
console.log($(this).data('events'));
}
*/

                //only stay in web app for links that are set to _self (or not set)
                if($(this).attr("target") == undefined || $(this).attr("target") == "" || $(this).attr("target") == "_self") {
                    //get the destination of the link clicked
                    var dest = $(this).attr("href");

                    //if the destination is an absolute url, ignore it
                    if(!dest.match(/^http(s?)/g)) {
                      //prevent default behavior (opening safari)
                      event.preventDefault();
                      //update location of the web app
                      self.location = dest;
                    }
                }
            });
        }
    } //end stayInWebApp func
});

})( jQuery );

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions