or with somethinh like (just copy and paste one of my code, just for the idea, it will not work as is) :
local http = require("socket.http")
local ltn12 = require("ltn12")
--(...)
local r, c, h = http.request{
method = "HEAD",
url = "http://myUrl/"..folder.."/"..fichier,
}
if c == 404 then
--print ("this "..fichier.." does not exist")
return false
end
if c == 200 then
myFile = io.open( dest\_folder.."/"..fichier, "w+b" )
local x,y = http.request{
url = "http://myURL/"..dossier.."/"..fichier,
sink = ltn12.sink.file( myFile ),
}
return true
end
Then you can parse the file and decide what to do. [import]uid: 5578 topic_id: 24291 reply_id: 117838[/import]
@Johantd04, You can move content around within the webview (like any browser window) but you cannot add a ātouchā listener to a webview. You can move the webview by changing itās x and y properties so you could move it by touching another display object outside of the webview. [import]uid: 7559 topic_id: 24291 reply_id: 117889[/import]
function listener( event )
local shouldLoad = true
local url = event.url
if 1 == string.find( url, "corona:close" ) then
-- Close the web popup
shouldLoad = false
end
if event.errorCode then
-- Error loading page
link.text = "Error: " .. tostring( event.errorMessage )
shouldLoad = false
end
return shouldLoad
end
-- Go Button Function
function goButton:tap(e)
native.showWebPopup( 10, 10, 300, 300, "http://www.anscamobile.com", {urlRequest=listener} )
-- Back button visibility
bottomBar.isVisible = true
back.isVisible = true
end
Its from the sample. But the webview just flushes. Doesnāt stay for a long time. Its just like a blink [import]uid: 104777 topic_id: 24291 reply_id: 119577[/import]
I also have a problem with native.newWebView when it encounters a web page redirect. If the web page that I try to view is redirected with a 302 redirect, I get a blank screen instead of the web page I want to view.
I do not know how to test for this using newWebView. So I tried using the network.request with a listener. But I have not been able to solve problem. Network.request seems to return nil for status.
If I use network.setStatusListener, it takes several minutes to get a status. Sometimes I get timeouts. Sometimes I get 200 for a status instead of 302.
Would like to be able use newWebView to display web pages without using network and checking for events.
Is there a way to overcome the problem with the redirected pages. The redirected pages display in Safari.
function listener( event )
local shouldLoad = true
local url = event.url
if 1 == string.find( url, "corona:close" ) then
-- Close the web popup
shouldLoad = false
end
if event.errorCode then
-- Error loading page
link.text = "Error: " .. tostring( event.errorMessage )
shouldLoad = false
end
return shouldLoad
end
-- Go Button Function
function goButton:tap(e)
native.showWebPopup( 10, 10, 300, 300, "http://www.anscamobile.com", {urlRequest=listener} )
-- Back button visibility
bottomBar.isVisible = true
back.isVisible = true
end
Its from the sample. But the webview just flushes. Doesnāt stay for a long time. Its just like a blink [import]uid: 104777 topic_id: 24291 reply_id: 119577[/import]
I also have a problem with native.newWebView when it encounters a web page redirect. If the web page that I try to view is redirected with a 302 redirect, I get a blank screen instead of the web page I want to view.
I do not know how to test for this using newWebView. So I tried using the network.request with a listener. But I have not been able to solve problem. Network.request seems to return nil for status.
If I use network.setStatusListener, it takes several minutes to get a status. Sometimes I get timeouts. Sometimes I get 200 for a status instead of 302.
Would like to be able use newWebView to display web pages without using network and checking for events.
Is there a way to overcome the problem with the redirected pages. The redirected pages display in Safari.
Iām at my witās end here. Webview is working great for me with one very minor, yet very ANNOYING exception.
Iām loading a webview with a remote HTML page. Iām loading up a back button that is dependent on the ācanGoBackā property. Unfortunately, the canGoBack option doesnāt fire every time so my back button isnāt always showing up when it is supposed to. Anyone else seen this?
Here is my code:
local webView = native.newWebView( 0, 100, 640, 589 )
webView:request( "http://www.MyRemoteWebPage.com/page1" )
local back = display.newImageRect( "btn-back.png", 160, 30 )
back.x = 90
back.y = 145
groupNews:insert( back )
local function webListener( event )
if webView.canGoBack == true then
back.isVisible = true
else
back.isVisible = false
end
end
local function backtap()
webView:back()
end
back:addEventListener("tap",backtap)
webView:addEventListener( "urlRequest", webListener )
Iāve been round and round this. Iāve tried checking the URL string instead of using canGoBackā¦same problem. What am I doing wrong? Anyone? Thanks.
[import]uid: 141982 topic_id: 24291 reply_id: 126633[/import]
The problem is the webView listener is called before the page is loaded so the canGoBack property isnāt valid yet. You need to poll it (with a timer) and check it when the page is loaded. I know this is a hack and the real solution is adding a listener that also fires when the page has finished loaded. Thatās on our to-do list. [import]uid: 7559 topic_id: 24291 reply_id: 126647[/import]
You said, āand check it when the page is loadedā but in the documentation I donāt see any way to find out whether the page has completed loading or not.
If thatās the case then the only option I can see is to continuously poll to see if .canGoBack is available and if it ever changes to true then show the button. Can you think of another way?
Jay [import]uid: 9440 topic_id: 24291 reply_id: 126668[/import]
@jay, you are correct. Thatās why I have put in a request for a ādidLoadā listener so we know when to test the status. Waiting a second and polling for a bit is the only solution I know of.
Tom [import]uid: 7559 topic_id: 24291 reply_id: 126685[/import]
Iām at my witās end here. Webview is working great for me with one very minor, yet very ANNOYING exception.
Iām loading a webview with a remote HTML page. Iām loading up a back button that is dependent on the ācanGoBackā property. Unfortunately, the canGoBack option doesnāt fire every time so my back button isnāt always showing up when it is supposed to. Anyone else seen this?
Here is my code:
local webView = native.newWebView( 0, 100, 640, 589 )
webView:request( "http://www.MyRemoteWebPage.com/page1" )
local back = display.newImageRect( "btn-back.png", 160, 30 )
back.x = 90
back.y = 145
groupNews:insert( back )
local function webListener( event )
if webView.canGoBack == true then
back.isVisible = true
else
back.isVisible = false
end
end
local function backtap()
webView:back()
end
back:addEventListener("tap",backtap)
webView:addEventListener( "urlRequest", webListener )
Iāve been round and round this. Iāve tried checking the URL string instead of using canGoBackā¦same problem. What am I doing wrong? Anyone? Thanks.
[import]uid: 141982 topic_id: 24291 reply_id: 126633[/import]
The problem is the webView listener is called before the page is loaded so the canGoBack property isnāt valid yet. You need to poll it (with a timer) and check it when the page is loaded. I know this is a hack and the real solution is adding a listener that also fires when the page has finished loaded. Thatās on our to-do list. [import]uid: 7559 topic_id: 24291 reply_id: 126647[/import]
You said, āand check it when the page is loadedā but in the documentation I donāt see any way to find out whether the page has completed loading or not.
If thatās the case then the only option I can see is to continuously poll to see if .canGoBack is available and if it ever changes to true then show the button. Can you think of another way?
Jay [import]uid: 9440 topic_id: 24291 reply_id: 126668[/import]
@jay, you are correct. Thatās why I have put in a request for a ādidLoadā listener so we know when to test the status. Waiting a second and polling for a bit is the only solution I know of.
Tom [import]uid: 7559 topic_id: 24291 reply_id: 126685[/import]
I can confirm this exact same problem.The window does not appear at the x, y coordinates you specify in the call, at least for iPad. I see many people in this thread reporting the same thing. Has anyone found a workaround yet?
I wouldnāt mind a workaround if I could predict precisely where the window will be but so far I cannot see what the pattern is. One thing is certain. The combination of letterbox and iPad makes the window appear in unpredictable places. It works fine on iPhone.
Thanks Tom. I tried 971, but just to help others that may find this thread, 971 release notes didnāt mention newWebView at all. Nevertheless I tried it and my code crashes on analytics. I see that 972 addresses analytics issues so hopefully that build will address both of these issues. [import]uid: 111723 topic_id: 24291 reply_id: 133535[/import]
The release build, 971 should not crash on analytics anymore. We fixed that in build 972 and ported the device templates so build 971 includes the fix.
The actual fix was not in build 971 but was included in the general release notes when we did a public release of 971:
OS: fixes casenum: 17123. If you call native.newWebViews(x,y,w,h) where x,y are not zero, then it would appear as if the webview were positioned at 2*x,2*y. This would cause touches to be clipped. This fixes both the positioning and touch clipping issues. [import]uid: 7559 topic_id: 24291 reply_id: 133539[/import]