I’m displaying a “webpage loading…” indicator while a webpage loaded with
webView = native.newWebView( 0, 0, 960, 600 )
webView:addEventListener( ‘urlRequest’, webListener )
webView:request( url )
I realize that on the first page load, native.newWebView shows a spinner while loading, but I’d like
to have my own indicator, and I’d like mine to also work when additional pages are loaded, i.e. when the user clicks links in the webpage being viewed and continues browsing.
I’m trying to understand how to know in webListener that the webpage has completely loaded and is finished?
webViews still don’t work at all in the MAC simulator, so my only way of trying to figure this out is on the iPhone 4s itself using native.showAlert’s.
The responses of the ‘urlRequest’ listener don’t seem to give what I need. event.url shows each time any sub-url in the page is loaded. This includes the ad pages, etc. So for one one page, event.url returns many different urls.
event.type returns often with the string “other”. I’m not sure how to understand what “other” means?
So it’s not clear when exactly the web page has finished loading, other than the “other” event.type’s eventually stop.
local function webListener( event )
if event.url then
end
if event.name then
native.showAlert( “Name:”, event.name, { “OK” } )
end
if event.type then
native.showAlert( “Type:”, event.type, { “OK” } )
end
if event.errorCode then
native.showAlert( “Error:”, event.errorMessage, { “OK” } )
end
end [import]uid: 176435 topic_id: 31194 reply_id: 331194[/import]