我有这个离子应用程序在webview中打开一个外部URL。我一直在测试ios模拟器,它工作正常,现在在Android模拟器上测试,但它不起作用。并且android监视器给了我以下错误调试消息。
08-11 19:28:52.229: D/cr_Ime(2813): [InputMethodManagerWrapper.java:56] isActive: true
08-11 19:28:52.229: D/cr_Ime(2813): [InputMethodManagerWrapper.java:65] hideSoftInputFromWindow
和以下错误消息
08-11 19:28:52.070: E/chromium(2813): [ERROR:gles2_cmd_decoder.cc(2109)] [.CommandBufferContext.RenderWorker-0xf43e1700]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM: <- error from previous GL command
08-11 19:28:52.096: E/chromium(2813): [ERROR:gles2_cmd_decoder.cc(2109)] [.CommandBufferContext.RenderWorker-0xf43e1700]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM: <- error from previous GL command
08-11 19:28:52.122: E/chromium(2813): [ERROR:gles2_cmd_decoder.cc(2109)] [.CommandBufferContext.RenderWorker-0xf43e1700]GL ERROR :GL_INVALID_OPERATION : GLES2DecoderImpl::DoBindTexImage2DCHROMIUM: <- error from previous GL command
08-11 19:28:52.226: E/chromium(2813): [ERROR:xwalk_autofill_client.cc(121)] Not implemented reached in virtual void xwalk::XWalkAutofillClient::OnFirstUserGestureObserved()
我完全失去了问题所在。
function createCORSRequest(method,url)
{
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr)
{
xhr.open(method, url, true);
}
else if (typeof XDomainRequest !== "undefined")
{
xhr = new XDomainRequest();
xhr.open(method, url);
}
else
{
xhr.open(method, url);
}
return xhr;
}
var formData = new FormData();
formData.append('portal[username]',name);
formData.append('portal[password]',password);
formData.append('portal[From]','web');
var url = endPoint+ '/login';
var xhr = createCORSRequest('POST', url);
xhr.onreadystatechange = function()
{
if (xhr.readyState === 4 && xhr.status === 200)
{
var jsonObj = JSON.parse(xhr.responseText);
var status = jsonObj.status;
var message = jsonObj.message;
if(status==='success')
{
var token = jsonObj.token;
home = 'http://127.0.0.1:8888/map/index?token='+token;
var ref = window.open(home,'_self');
ref.addEventListener('loadstart', function(event)
{
if (event.url == "http://127.0.0.1:8888/map/logout")
{
ref.close();
}
});
}
else
{
alert(message);
}
}
};
xhr.send(formData);
答案 0 :(得分:0)
您应该可以使用$cordovaInAppBrowser插件打开网址。
$cordovaInAppBrowser.open('http://example.com', '_system');
我相信您还必须在config.xml中授予外部网址的权限
<allow-navigation href="http://example.com/*"/>