Display an image until a web popup loads

I have a simple web popup. When a button is tapped a web popup opens. The code is as follows:

local goButton = display.newImage("go\_button.png") goButton.x = display.contentWidth \* 0.5 goButton.y = display.contentHeight  \* 0.5 function goButton:tap(e) local scale0= ((display.actualContentWidth- display.contentWidth)\*.5)\*-1 local scale0Y= ((display.actualContentHeight- display.contentHeight)\*.5)\*-1 native.showWebPopup( scale0, scale0Y, display.actualContentWidth, display.actualContentHeight ,"https://coronalabs.com/") end goButton:addEventListener("tap", goButton)

Now when I tap on the “Go” button it shows a white screen until it loads the website. I want to displays an image until the webpopup loads fully.

I tried this:
 

local function onWebViewEvent(event)   if not "loaded" == event.type then     print("Loading: ", event.url )   end end local scale0= ((display.actualContentWidth- display.contentWidth)\*.5)\*-1 local scale0Y= ((display.actualContentHeight- display.contentHeight)\*.5)\*-1 local webView = native.newWebView( scale0, scale0Y, display.actualContentWidth, display.actualContentHeight ) webView:addEventListener("urlRequest", onWebViewEvent) webView:request("http://www.coronalabs.com")

You can’t really draw anything on top of the webView.

Rob

You can move the webview away and when loaded bring it back

@scottrules44
Can you please suggest how can I do that?

Before webView:request
Do
webView.x=-10000000
In you onWebViewEvent do
if event.type == “loaded” then
webView.x =scale0
end

Ok… Thanks a lot.

@scottrules44

This is my updated code: 
Is it ok? 

local function listener(event) if event.type == "loaded" then webView.x =scale0 end  end local scale0= ((display.actualContentWidth- display.contentWidth)\*.5)\*-1 local scale0Y= ((display.actualContentHeight- display.contentHeight)\*.5)\*-1 local webView = native.showWebPopup( -10000000, scale0Y, display.actualContentWidth, display.actualContentHeight ,"http://www.coronalabs.com/", {urlRequest = listener})

You should not change to show web popup.

Edit: documentation “webpop ups cannot be moved or resized”

Ok. Thanks, but I have a problem with webView it shows two white ribbons in top and bottom and I cannot mange to resize it to fit the screen automatically depending on the device screen size.

[sharedmedia=core:attachments:5351]
[sharedmedia=core:attachments:5352]
 

I try this, but only the default background is visible instead of the webview
 

local function webListener(event)   if event.type == "loaded" then    webView.x =0   end  end local webView = native.newWebView( display.contentCenterX, display.contentCenterY, 320, 480 ) webView:request( "http://gogols.in/" ) webView.x=-10000000 webView:addEventListener( "urlRequest", webListener )

It is supposed to move until the page is loaded

After the background screen come, nothing happens. The screen freezes.

You can’t really draw anything on top of the webView.

Rob

You can move the webview away and when loaded bring it back

@scottrules44
Can you please suggest how can I do that?

Before webView:request
Do
webView.x=-10000000
In you onWebViewEvent do
if event.type == “loaded” then
webView.x =scale0
end

Ok… Thanks a lot.

@scottrules44

This is my updated code: 
Is it ok? 

local function listener(event) if event.type == "loaded" then webView.x =scale0 end  end local scale0= ((display.actualContentWidth- display.contentWidth)\*.5)\*-1 local scale0Y= ((display.actualContentHeight- display.contentHeight)\*.5)\*-1 local webView = native.showWebPopup( -10000000, scale0Y, display.actualContentWidth, display.actualContentHeight ,"http://www.coronalabs.com/", {urlRequest = listener})

You should not change to show web popup.

Edit: documentation “webpop ups cannot be moved or resized”

Ok. Thanks, but I have a problem with webView it shows two white ribbons in top and bottom and I cannot mange to resize it to fit the screen automatically depending on the device screen size.

[sharedmedia=core:attachments:5351]
[sharedmedia=core:attachments:5352]