Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change url of cordova inAppBrowser

I want to programmatically change cordova inAppBrowser's url when user clicked a notification. I have searched but nothing found. i have tried:

var theurl,newurl,ref;

theurl = 'http://example1.com';
newurl = 'http://example2.com';
function a(){
    ref = window.open(theurl, '_blank', 'location=no,hidden=yes,toolbar=no,EnableViewPortScale=yes,zoom=no');
}
function b(){
    ref.location.href = newurl;
}

i also tried this:

function b(){
    ref.url = newurl;
}

But, it seems like not working, is there any code?

like image 339
dian Avatar asked Oct 30 '25 03:10

dian


1 Answers

Finally i've found the solution. I am using executeScript method to change the url via javascript. here is what i do:

function b(){
    ref.executeScript({
        code: "window.location = '"+newurl+"';"
    }, function() {
        //alert("Redirected!");
    });
}
like image 94
dian Avatar answered Oct 31 '25 22:10

dian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!