Help Me, cannot native.cancelWebPopup

Please see my source code as below.

I would like to close pop up page when click some button and do next task, but cannot

If I use href=“corona:close”, it will be webkit errorCode=-10 (wrong url)

But if I use href=“http://www.corona:close”, it’s redirect to http://www.corona:close web which is unavailable.

What wrong on my source code, please advice…

Thank you

=========================

local function showIntro(view)

    native.showWebPopup(“http://www.xxx.com/testLink.jsp”, options)

    local options =

    {       

        hasBackground = false,  – default: true

        autoCancel = true,  – default: true (android)

        urlRequest = webListener  – default: nil

    }

end   

 

 

function webListener(event)

   local shouldLoad = false

   native.cancelWebPopup()

   --do next task

   return shouldLoad

end

function scene:enterScene( event )

    print(“enterScene”)

    local group = self.view

    showIntro(group)

end

 

 

 

==============

testLink.jsp

==============

<a href=“corona:close”>image</a>

If this is your exact code, then the problem is that you defined your webListener function after you created the webView.  What that means is that, at the time you create the webView, webListener is nil, so the urlRequest listener doesn’t do anything.  Try moving your definition of the webListener function before you create the webView and see if that helps.

  • Andrew

If this is your exact code, then the problem is that you defined your webListener function after you created the webView.  What that means is that, at the time you create the webView, webListener is nil, so the urlRequest listener doesn’t do anything.  Try moving your definition of the webListener function before you create the webView and see if that helps.

  • Andrew