object:request()

Type Function
Object WebView
Library native.*
Return value none
Revision Release 2022.3683
Keywords request

Overview

Loads the specified URL (string) into the WebView. For local content, you must specify a base system directory as a search path.

Syntax

object:request( url )
object:request( url, baseDir )
url (required)

String. The URL to load. For local files, this is a path relative to baseDir.

baseDir (optional)

Constant. A base directory constant.

Gotchas

On Android, if the web view is displaying web pages from the Internet, you must add the INTERNET permission to the build.settings file. This permission is unnecessary if the web view will only be displaying local HTML files that do not access the Internet.

settings =
{
    android =
    {
        usesPermissions =
        {
            "android.permission.INTERNET",
        },
    },
}

Example

local webView = native.newWebView( 0, 0, 320, 480 )
webView:request( "https://solar2d.com/" )