preload Function

Callable

  • preload( ) : void
  • Preloads resources of the web-to-print editor.

    example
    <!DOCTYPE html>
    
    <html lang="en">
    
    <head>
        <meta charset="utf-8" />
        <title>Customer's Canvas Quick Start Sample Page</title>
        <!-- The IFrame API script. IMPORTANT! Do not remove or change the ID. -->
        <script id="CcIframeApiScript" type="text/javascript" src="/cc/Resources/SPEditor/Scripts/IFrame/IframeApi.js">
        </script>
        <!-- Preloading resources of the editor. -->
        <script>CustomersCanvas.IframeApi.preload();</script>
    </head>
    
    <body>
        <!-- The iframe to display the editor in. -->
        <iframe id="editorFrame" width="100%" height="800px"></iframe>
    </body>
    
    <script>
        // Initializing a product with only one template - "BusinessCard.psd".
        var productDefinition = { surfaces: ["BusinessCard"] };
        // Providing the tokenId, which is required to access the Image Gallery.
        var config = { tokenId: "95c16577-75fe-4145-87ff-c0ba49d1a554" };
        // Getting the iframe element to display the editor in.
        var iframe = document.getElementById("editorFrame");
        var editor = null;
        // Loading the editor.
        CustomersCanvas.IframeApi.loadEditor(iframe, productDefinition, config)
            // If the editor has been successfully loaded.
            .then(function (e) {
                editor = e;
            })
            // If there was an error thrown when loading the editor.
            .catch(function (error) {
                console.error("The editor failed to load with an exception: ", error);
            });
    </script>
    
    </html>
    

    Returns void