Custom error "webpage not available” (WebView)

Inkeliz

New Member
Hi,
I can change the "page not available" page?

example:
I start the application, but I do not have 3G or WIFI.
And, the app shows "page not available". But this error showing the URL.


I can do a 'custom error', located in 'file:///android_asset/erro.html' for exemple?
And if you have no connection, this new page (file:///android_asset/erro.html) appears.

*Sorry for my english

My aplication: ("-LINK-" is the URL for my website)
B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("WebViewer")
   WebView1.LoadUrl("-LINK-")
   WebView1.Width = 100%x
   WebView1.Height = 100%y
End Sub

Sub activity_KeyPress (KeyCode As Int) As Boolean 

If KeyCode = KeyCodes.KEYCODE_BACK Then
WebView1.Back
Return True
End If

If KeyCode = KeyCodes.KEYCODE_MENU Then
WebView1.LoadUrl("-LINK-/config.php")
Return True
End If

End Sub
 

nso91191

Member
Licensed User
Longtime User
Hello @Erel

how to convert b4a code :(

i want to hide error in webview (loadurl )

i want to show custom error page


B4X:
var wv = Ti.UI.createWebView({
url:'http://developer.appcelerator.com/questionsdfd/130976'
});

var xhr = Ti.Network.createHTTPClient();
xhr.onload = foo;
xhr.open('GET', 'http://developer.appcelerator.com/questionsdfd/130976');
xhr.send();

var win = Ti.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' });
win.add(wv);
win.open();

function foo() {
if (this.status == 404) {
alert('Got 404 error - WebView will be hidden.');
wv.hide();
}
};
 
Last edited:
Upvote 0
Top