network request with local html files in webView

Hi my friend

can someone explain to me how to find the same result with local html files in webView


local function networkListener( event )
    if ( event.isError ) then
       print( "Network error: ", event.response ) 
      
    elseif ( event.phase == "began" ) then
        if ( event.bytesEstimated <= 0 ) then
           
            print( "Download starting, size unknown" )
        
        else
            print( "Download starting, estimated size: " .. event.bytesEstimated )
          
        end

    elseif ( event.phase == "progress" ) then
        if ( event.bytesEstimated <= 0 ) then
           
            print( "Download progress: " .. event.bytesTransferred )
          
        else
            print( "Download progress: " .. event.bytesTransferred .. " of estimated: " .. event.bytesEstimated )
               end
        
    elseif ( event.phase == "ended" ) then
        print( "Download complete, total bytes transferred: " .. event.bytesTransferred )
    
    end
end
 
local params = {}

-- Tell network.request() that we want the "began" and "progress" events:
params.progress = "download"

-- Tell network.request() that we want the output to go to a file:
params.response = {

      filename = "video2.mp4",

    baseDirectory = system.DocumentsDirectory
}

network.request( "https://www.mysite.com/myVideo.mp4", "GET", networkListener,  params )



local webView = native.newWebView( display.contentCenterX, display.contentCenterY, 760, 1024 )
webView:request( "page1.html", system.DocumentsDirectory )

I want to know what should i write in page1.html to download and save the file

my page1

<!DOCTYPE html>
<html>
<head>
<title>Page Title </title>
</head>
<body>

<h1>Head</h1>


<h2>Page1</h2>
<p>my work.</p>

</body>

<a href=page2.html>Visit page 2 !</a>

</p>

<a href="https://www.rapidtables.com/web/html/link/test_file.zip" download>Download File</a>

</html>
</body>
</html>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.