HtmlFormatHelper.GetStaticFragment(String) メソッド

定義

HTML フラグメントを表す文字列を取得します。

public:
 static Platform::String ^ GetStaticFragment(Platform::String ^ htmlFormat);
 static winrt::hstring GetStaticFragment(winrt::hstring const& htmlFormat);
public static string GetStaticFragment(string htmlFormat);
function getStaticFragment(htmlFormat)
Public Shared Function GetStaticFragment (htmlFormat As String) As String

パラメーター

htmlFormat
String

Platform::String

winrt::hstring

書式設定された HTML。

戻り値

String

Platform::String

winrt::hstring

書式設定された HTML に基づく HTML フラグメント。

if (shareOperation.data.contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.html)) {
    document.getElementById("htmlContentArea").className = "unhidden";
    
    shareOperation.data.getHtmlFormatAsync().then(function (html) {
        if (html !== null) {
            var htmlFragment = Windows.ApplicationModel.DataTransfer.HtmlFormatHelper.getStaticFragment(htmlFormat);

            // Set the innerHTML of the ifram to the HTML fragment.
            var iFrame = document.getElementById("htmlContent");
            iFrame.style.display = "";
            iFrame.contentDocument.documentElement.innerHTML = htmlFragment;
        } 
    });

    // Loop through any images and use the resourceMap to map each image element's src.
    var images = iFrame.contentDocument.documentElement.getElementsByTagName("img");
    if (images.length > 0) {
        shareOperation.data.getResourceMapAsync().done(function (resourceMap) {
            if (resourceMap.size > 0) {
                for (var i = 0, len = images.length; i < len; i++) {
                    var streamReference = resourceMap[images[i].getAttribute("src")];
                    if (streamReference) {
                        // Call a helper function to map the image element's src to a corresponding blob URL generated from the streamReference
                        setResourceMapURL(streamReference, images[i]);
                    }
                }
            }
        });
}
//shareOperation.reportCompleted();

注釈

セキュリティ上の注意として、動的コンテンツがないことを確認しない限り、HTML を表示しないでください。 メソッドを GetStaticFragment 使用すると、スクリプト タグなどの動的要素なしで共有 HTML コンテンツを取得できます。

適用対象