DataPackage.SetHtmlFormat | setHtmlFormat method
Adds HTML content to the DataPackage.
Syntax
dataPackage.setHtmlFormat(value);
Parameters
- value
-
Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]
The HTML content.
Remarks
To ensure that a target app can process the HTML content, use HtmlFormatHelper.CreateHtmlFormat. It adds the required headers and other information the string containing the HTML.
If your app supports selection or copying/pasting of HTML content that contains img elements, be sure that the src attributes specify fully-qualified absolute paths to the images, not relative paths.
Windows Phone 8
This API is not implemented and will throw an exception if called.
Examples
function shareHtmlHandler(e) { var request = e.request; var htmlExample = "<p>Here is our store logo: <img src='images/logo.png'>.</p>"; var localImage = "images\\logo.png"; request.data.properties.title = "Share Html Example"; request.data.properties.description = "A demonstration that shows how to share an HTML fragment with a local image."; var deferral = e.request.getDeferral(); Windows.ApplicationModel.Package.current.installedLocation.getFileAsync(localImage).done(function (imageFile) { request.data.setHtmlFormat(Windows.ApplicationModel.DataTransfer.HtmlFormatHelper.createHtmlFormat(htmlExample)); request.data.resourceMap[localImage] = Windows.Storage.Streams.RandomAccessStreamReference.createFromFile(imageFile); deferral.complete(); }, function (err) { request.failWithDisplayText(err); }); }
Requirements
|
Minimum supported client | Windows 8 |
|---|---|
|
Minimum supported server | Windows Server 2012 |
|
Minimum supported phone | Windows Phone 8 |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 2/25/2013
