WebView.LoadDataWithBaseURL(String, String, String, String, String) Method

Definition

Loads the given data into this WebView, using baseUrl as the base URL for the content.

[Android.Runtime.Register("loadDataWithBaseURL", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", "GetLoadDataWithBaseURL_Ljava_lang_String_Ljava_lang_String_Ljava_lang_String_Ljava_lang_String_Ljava_lang_String_Handler")]
public virtual void LoadDataWithBaseURL (string? baseUrl, string data, string? mimeType, string? encoding, string? historyUrl);
[<Android.Runtime.Register("loadDataWithBaseURL", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", "GetLoadDataWithBaseURL_Ljava_lang_String_Ljava_lang_String_Ljava_lang_String_Ljava_lang_String_Ljava_lang_String_Handler")>]
abstract member LoadDataWithBaseURL : string * string * string * string * string -> unit
override this.LoadDataWithBaseURL : string * string * string * string * string -> unit

Parameters

baseUrl
String

the URL to use as the page's base URL. If null defaults to 'about:blank'.

data
String

a String of data in the given encoding

mimeType
String

the MIME type of the data, e.g. 'text/html'.

encoding
String

the encoding of the data

historyUrl
String

the URL to use as the history entry. If null defaults to 'about:blank'. If non-null, this must be a valid URL.

Attributes

Remarks

Loads the given data into this WebView, using baseUrl as the base URL for the content. The base URL is used both to resolve relative URLs and when applying JavaScript's same origin policy. The historyUrl is used for the history entry.

The mimeType parameter specifies the format of the data. If WebView can't handle the specified MIME type, it will download the data. If null, defaults to 'text/html'.

Note that content specified in this way can access local device files (via 'file' scheme URLs) only if baseUrl specifies a scheme other than 'http', 'https', 'ftp', 'ftps', 'about' or 'javascript'.

If the base URL uses the data scheme, this method is equivalent to calling #loadData(String,String,String) loadData() and the historyUrl is ignored, and the data will be treated as part of a data: URL, including the requirement that the content be URL-encoded or base64 encoded. If the base URL uses any other scheme, then the data will be loaded into the WebView as a plain string (i.e. not part of a data URL) and any URL-encoded entities in the string will not be decoded.

Note that the baseUrl is sent in the 'Referer' HTTP header when requesting subresources (images, etc.) of the page loaded using this method.

If a valid HTTP or HTTPS base URL is not specified in baseUrl, then content loaded using this method will have a window.origin value of "null". This must not be considered to be a trusted origin by the application or by any JavaScript code running inside the WebView (for example, event sources in DOM event handlers or web messages), because malicious content can also create frames with a null origin. If you need to identify the main frame's origin in a trustworthy way, you should use a valid HTTP or HTTPS base URL to set the origin.

Java documentation for android.webkit.WebView.loadDataWithBaseURL(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to