Cordova Inappbrowser - window.history.back and forward won't work inside executescript function

1.7k views Asked by At

I set the location to no to hide the default bar of the in-app browser and used inserts and execute a script to create my own bar. The rest of the buttons I added are working except for the back and a forward button that I created. I've already tried

navigator.app.backHistory();
window.history.back();
window.history.go(-1);
history.go(-1);
history.back();
history.go(-1);

but not of them works. I will be compiling this app in Android and ios.

1

There are 1 answers

0
Johanna Cristine Dy On BEST ANSWER

Never mind. I got used to how I did my other buttons where i had to use functions from cordova plugins. That is why i put in in a callback of an executescript within the callback of another execute script which calls a file: 'externaljavascriptfile.js'

I just realized, I didn't have to do that. and just put

    window.history.back();

and

    window.history.forward();

in the js file ^^; Silly mistake :B

    $('body').on('click','#customheader-back',function()
    {
        window.history.back();
    });

    $('body').on('click','#customheader-forward',function()
    {
        window.history.forward();
    });