当前位置: 动力学知识库 > 问答 > 编程问答 >

angularjs - How to add a custom error page in Cordova InAppBrowser or hide the error url?

问题描述:

pleas check this attached image I'm building an Ionic Android app with the InAppBrowser plugin. When the internet connection is not available, the plugin shows web page not available and requesting url.

Please help me customise the InAppBrowser error page (404 page). Or help me hide the requesting url.

Thank you.

网友答案:

I think I misunderstood your problem, first time, sorry about that. I'm reading again your problem and I'm figuring out what's happening. You need to add a custom configuration at config.xml to redirect to an error page when Cordova detect it. I hope this solve your problem.

<preference name="ErrorUrl" value="myErrorPage.html"/>

The original response works when you want to open a link through Cordova inAppBrowser plugin. If this doesn't sort out your problem, please reformulate your question.

Original response

You could be listening inAppBrowser events to figure what's happening.

Here, you can see how listen browser events, such as loaderror and manage the 404 error as you want. You must save a reference to inAppBrowser when open method is called, and then you could listen for error event.

function loadErrorCallBack(params) {
    // Do stuff
}

inAppBrowserRef = cordova.InAppBrowser.open(url, target, options);
inAppBrowserRef.addEventListener('loaderror', loadErrorCallBack);
分享给朋友:
您可能感兴趣的文章:
随机阅读: