在AppBrowser中更改cordova的url

问题描述 投票:0回答:1

当用户单击通知时,我想以编程方式更改 AppBrowser 中的 cordova 网址。我已经搜索过但一无所获。 我试过了:

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;
}

我也尝试过这个:

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

但是好像不行,有代码吗?

cordova inappbrowser
1个回答
8
投票

终于找到解决办法了。我正在使用executeScript 方法通过javascript 更改url。这就是我所做的:

function b(){
    ref.executeScript({
        code: "window.location = '"+newurl+"';"
    }, function() {
        //alert("Redirected!");
    });
}
© www.soinside.com 2019 - 2024. All rights reserved.