Javascript 如何在InAppBrowser Cordova中获取当前链接
大家好,我在Xcode v6.1、Cordova v3.7和jquerymobile v1.4.5中工作 我有一个列表,其中有外部站点的URL。单击将打开InAppBrowser的任何站点时,我想在InAppBrowser页面中导航。例如,我在索引页面中,单击或注册页面后,如何从InAppBrowser获取当前url。我知道InAppBrowser退出事件,但找不到当前url。这是密码Javascript 如何在InAppBrowser Cordova中获取当前链接,javascript,cordova,url,Javascript,Cordova,Url,大家好,我在Xcode v6.1、Cordova v3.7和jquerymobile v1.4.5中工作 我有一个列表,其中有外部站点的URL。单击将打开InAppBrowser的任何站点时,我想在InAppBrowser页面中导航。例如,我在索引页面中,单击或注册页面后,如何从InAppBrowser获取当前url。我知道InAppBrowser退出事件,但找不到当前url。这是密码 function innAppInit(_url) { try { ap
function innAppInit(_url) {
try {
app.Log('browser news link=' + _url);
if (_url == null) {
_url = 'http://apache.org';
}
var ref = window.open(encodeURI(_url), '_blank', 'location=no');
console.Dir(ref);
ref.addEventListener('loadstart', function(event) {
$('.ui-loader').hide();
});
ref.addEventListener('exit', function(event) {
alert('exit');
console.Dir(this);
// **how to get current url here;**
});
} catch (e) {
console.log(e);
}
}
如果发生loadstart,您就可以使用它:
var ref = window.open(encodeURI(_url), '_blank', 'location=no');
ref.addEventListener('exit', function()
{
alert(event.url); // here you have the URL
});
有关更多信息,请参见警报(event.url);//这里有一个URL,返回exituse事件退出后未定义的想要的URL,
ref.addEventListener('exit',function(event){alert(event.type);})代码>如果在退出事件中找不到url,则应将其保存在先前事件中的变量中,并在退出时使用它。。。