This topic describes the JavaScript API of WVScreenCapture. You can refer to this topic when you create HTML5 apps or Miniapps. You can use the JavaScript API of WVScreenCapture to take screenshots.
WVScreenCapture.capture
This API is available only in Windvane Android 1.0.3.4 or later.
In Windvane Android 1.0.3.3 and earlier, please call WVScreen.capture. The input parameters and callback parameters of WVScreen.capture are the same as those of WVScreenCapture.capture.
Takes a screenshot of the current viewing window of WebView.
In iOS 11, you need to add the "NSPhotoLibraryAddUsageDescription" key to the Info.plist. This key lets you describe the reason why the app is requesting access to the user's album.
Input parameters
[
String]inAlbum: specifies whether to save the screenshot as an image file in the album.'true'specifies to save the screenshot as an image file in the album.'false'specifies not to save the screenshot. Default value:'false'.[
String]type: the type of the screenshot.'view'specifies to take a screenshot of the current viewing window of WebView.'app'specifies to take a screenshot of the app window. Default value:'view'. If you specify'app'as the parameter value, the screenshot includes the status bar. For some Android models that have soft keyboards, such as the Smartbar, the soft keyboard section will be rendered as a black background in the screenshot.
Callback parameters
Callback parameters are passed by using the callback method. If a screenshot was taken, the success callback is invoked. Otherwise, the failure callback is invoked.
[
string]url: the access URL. The URL of the page is filled in thesrcproperty ofimgfor the preview of the screenshot.NoteThis URL is not an actual content delivery network (CDN) URL and cannot be accessed from a browser.
[
string]localPath: the local path of the screenshot. This path can be used when you call WVCamera.confirmUploadPhoto to upload photos to CDN.
var params = {
// Specify whether to save the screenshot as an image file in the album.
inAlbum: 'true'
};
window.WindVane.call('WVScreenCapture', 'capture', params, function(e) {
alert('success: ' + JSON.stringify(e));
}, function(e) {
alert('failure: ' + JSON.stringify(e));
});