Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

webview Listener html body
Started by kakula Oct 31 2018 01:58 AM

2 replies to this topic
webview listener html body
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

kakula

[GLOBAL: userInfoPane.html]
kakula
  • Contributor

  • 103 posts
  • Corona SDK

Hi,

 

for webviews

 

is there a way to read the html content of a webview through the listener (for example   print(event.html) or print(event.body))

 

local function webListener( event )
    if event.url then
--     print(event.html) or print(event.body)
        print( "You are visiting: " .. event.url )
    end
  
    if event.type then
        print( "The event.type is " .. event.type ) -- print the type of request
    end
  
    if event.errorCode then
        native.showAlert( "Error!", event.errorMessage, { "OK" } )
    end
end
webView = native.newWebView( display.contentCenterX, display.contentCenterY-100, display.contentWidth, display.contentHeight-200)
    webView:request( "www.coronalabs.com" )
webView:addEventListener( "urlRequest", webListener )

 



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,197 posts
  • Enterprise

Not that I'm aware of.  Corona can detect when links are interacted with and you can get the URL that was interacted with. If that URL has HTTP style GET key-value pair parameters, you could parse that data out and get information that way.

 

Rob



[TOPIC: post.html]
#3

anaqim

[GLOBAL: userInfoPane.html]
anaqim
  • Contributor

  • 770 posts
  • Corona SDK

Thats too bad cause i need to use a webview for an API login and while it happens rarely, it does happen that the view gets a load error and displays data, i'd not wish to show, but there is no way to detect when that happens. Printing web listener data lists nothing when that happens.




[topic_controls]
[/topic_controls]