Closing Newwebview With An Html Button

Hi all, I am creating a newWebview which loads a local html file.

This all works fine.

I am having trouble closing the webview with a button from within the html file.

here is my code:

local function webListener( event ) local theurl = event.url if theurl == "corona:close" then -- remove the webView as with any other display object webView:removeSelf() webView = nil end end local webView = native.newWebView( 0, 0, thewidth, theheight ) webView:request( therequesturl,system.ResourceDirectory ) webView:addEventListener('urlRequest',webListener)

and in my html file i have:

\<form action="corona:close"\>\<input type="submit" value="" id="closebtn"/\>\</form\>

this used to work with webpopups. Anyone have an idea what I might be missing with this?

thanks in advance!

Have you looked at the sample app in the SampleCode/Interface/WebOverlay folder?

Yes, that sample is a webpopup and for some reason, the same logic doesn’t seem to apply to a native webview as used in the code sample above. Any ideas what I can do to get this working?

Have you looked at the sample app in the SampleCode/Interface/WebOverlay folder?

Yes, that sample is a webpopup and for some reason, the same logic doesn’t seem to apply to a native webview as used in the code sample above. Any ideas what I can do to get this working?

Have you had any progress on this issue? I’m also trying to setup listeners/web-side actions and I’m having some trouble getting data from the webview. 

I’ve had success with webpopup, but webView seems to operate differently.

Have you had any progress on this issue? I’m also trying to setup listeners/web-side actions and I’m having some trouble getting data from the webview. 

I’ve had success with webpopup, but webView seems to operate differently.

Maybe you’ve removed some other parts of the code, but it seems like “webView” object wouldn’t be in-scope when the “webListener” function gets executed (since you create the webview, then control is passed back to the runtime, then at some later time the listener gets called).

… though I must admit I’m still getting my head around some parts of Lua.

Maybe you’ve removed some other parts of the code, but it seems like “webView” object wouldn’t be in-scope when the “webListener” function gets executed (since you create the webview, then control is passed back to the runtime, then at some later time the listener gets called).

… though I must admit I’m still getting my head around some parts of Lua.