Announcement

Collapse
No announcement yet.

How to disable device Back button (pc, tablet and mobile)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to disable device Back button (pc, tablet and mobile)

    Hi,

    Just want to share an usefull function : disable or control back button on page

    insert this lines in OnApllicationInit event :

    echo "<script type='text/javascript'>
    if( window.history && window.history.pushState ){
    history.pushState( 'nohb', null, '' );
    $(window).on( 'popstate', function(event){
    if( !event.originalEvent.state ){
    history.pushState( 'nohb', null, '' );
    return;
    }
    });
    }
    </script>";


    Nac

  • #2
    I will try, thanks for share
    /Giuseppe

    Professional Scriptcase Services
    Some Customers opinions

    Comment


    • #3
      Doesn't work with Control App in OnApplicationInit event but well if you put it on header variable in Layout Setting : for ex: in a global variable
      Last edited by nacyil; 05-05-2016, 06:37 AM.

      Comment


      • #4
        Wauw, what a great solution to a big problem. Tnx for sharing, in the header it works like charm!
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          Didnt tried yet, but I guess for projects with menu shouod work using this just in menu right?
          /Giuseppe

          Professional Scriptcase Services
          Some Customers opinions

          Comment


          • #6
            just in menu app is enough

            Comment


            • #7
              Under menu you have to add JQuery:
              PHP Code:
              echo "<script type="text/javascript" src="" . $_SESSION['scriptcase']['menu']['glo_nm_path_prod'] . "/third/jquery/js/jquery.js"></script>"
              But, don't works for me. Back button still working
              /Giuseppe

              Professional Scriptcase Services
              Some Customers opinions

              Comment


              • #8
                Put in onapplicationinit of the menu:

                Code:
                [glob_disable]="<script type='text/javascript'>
                if( window.history && window.history.pushState ){
                history.pushState( 'nohb', null, '' );
                $(window).on( 'popstate', function(event){
                if( !event.originalEvent.state ){
                history.pushState( 'nohb', null, '' );
                return;
                }
                });
                }
                </script>";
                Then enable header and put in one of the templatevariables [glob_disable].'your regular text if any'

                That works for me.
                Albert Drent
                aducom software netherlands
                scriptcase partner, reseller, support and (turn-key) development
                www.scriptcase.eu / www.scriptcase.nl

                Comment


                • #9
                  Originally posted by aducom View Post
                  Put in onapplicationinit of the menu:

                  Code:
                  [glob_disable]="<script type='text/javascript'>
                  if( window.history && window.history.pushState ){
                  history.pushState( 'nohb', null, '' );
                  $(window).on( 'popstate', function(event){
                  if( !event.originalEvent.state ){
                  history.pushState( 'nohb', null, '' );
                  return;
                  }
                  });
                  }
                  </script>";
                  Then enable header and put in one of the templatevariables [glob_disable].'your regular text if any'

                  That works for me.
                  You are right. Curious why is not working in the other way.
                  /Giuseppe

                  Professional Scriptcase Services
                  Some Customers opinions

                  Comment


                  • #10
                    Originally posted by aducom View Post
                    Put in onapplicationinit of the menu:

                    Then enable header and put in one of the templatevariables [glob_disable].'your regular text if any'

                    That works for me.
                    This is a God sent solution: thanks you all.

                    Will try but please clarify to me what the above section is doing. The header is enabled but how/ where exactly do I put [glob_disable].'my regular text'. In my case, the only header variable I am using is LIN1_COL1 and it is set to image.

                    Thanks in advance.

                    Comment


                    • #11
                      If your header template has more than one field use a free one, setting it to type value. If you haven't then choose a header template that has more than one field (afaik all default have).
                      Albert Drent
                      aducom software netherlands
                      scriptcase partner, reseller, support and (turn-key) development
                      www.scriptcase.eu / www.scriptcase.nl

                      Comment


                      • #12
                        Unfortunately this solution is not quite fail proof. It does not seem to work on Chrome (50) en IE (11).
                        Albert Drent
                        aducom software netherlands
                        scriptcase partner, reseller, support and (turn-key) development
                        www.scriptcase.eu / www.scriptcase.nl

                        Comment


                        • #13
                          Hello,

                          Good morning guys, I have a question. Could you provide me an example case where you need to disable device back button? Thank you in advance.

                          Comment


                          • #14
                            so any clues why it is not working in CHROME ? any workarounds ?
                            -----------------------------------------
                            Arthur Klisiewicz
                            dATA POINT SOFTWARE
                            www.datapointsoftware.com

                            Comment

                            Working...
                            X