尼古拉斯炒饭
尼古拉斯炒饭
  • 发布:2017-12-30 17:01
  • 更新:2018-01-02 12:15
  • 阅读:4653

ios下页面中调用plus.webview.currentWebview()无法获取getUrl()

分类:HTML5+

function plusReadyforPage(){
var nowView = plus.webview.currentWebview();
console.log( "窗口ID:"+nowView.id ); <-这个有值
console.log( "窗口URL:"+nowView.getURL() ); <----这个除非除非在联机保存时刷新才跳出值
}

if(window.plus){
plusReadyforPage();
}else{
document.addEventListener('plusready', plusReadyforPage, false);
}

貌似android下都好用,但是ios下 ,getURL() 返回空值。

2017-12-30 17:01 负责人:无 分享
已邀请:
hylong

hylong

getURL()是当页面loaded之后才能获取。有两种方法获取当前当前页面url。
可以直接使用location.href
或者

var nowView = plus.webview.currentWebview();  
                nowView.addEventListener('loaded',function () {  
                    alert(wv.getURL());  
                });

该问题目前已经被锁定, 无法添加新回复