将HTML文件内容加载到Dojo对话框中

7eumitmz  于 2022-12-16  发布在  Dojo
关注(0)|答案(1)|浏览(164)

我想加载一个HTML文件到一个dojo对话框中。下面是我的HTML文件:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Demo</title>
    </head>
    <body>
        <canvas width=500 height="240" id="canvas"></canvas>
        <hr>
       <input type="button" id="upload" value="upload" onclick="decodeLocalImage();">
        <ul></ul>
        <script type="text/javascript" src="filereader.js"></script>
        <script type="text/javascript" src="qrcodelib.js"></script>
        <script type="text/javascript" src="webcodecamjs.js"></script>
        <script type="text/javascript">

            var txt = "innerText" in HTMLElement.prototype ? "innerText" : "textContent";
            var arg = {
                resultFunction: function(result) {
                    var aChild = document.createElement('li');
                    aChild[txt] = result.format + ': ' + result.code;
                    document.querySelector('body').appendChild(aChild);
                }
            };
            var decoder = new WebCodeCamJS("canvas").init(arg);

            function decodeLocalImage(){
                decoder.decodeLocalImage();
            }

        </script>
    </body>
</html>

这是我如何制作对话框的:

this.scanDialog = new Dialog({
                title: dojoConfig.i18n.productCode,
                style: "width: 900px",
                showTitle:true,
                dimensions:[900,150],
                'class': 'dialogStyle'
            });

所以我的问题是如何将HTML文件加载到对话框中?

ct2axkht

ct2axkht1#

您可以使用href属性加载外部对话框内容,如下所示:

this.scanDialog = new Dialog({
            title: dojoConfig.i18n.productCode,
            style: "width: 900px",
            showTitle:true,
            dimensions:[900,150],
            'class': 'dialogStyle',
              href: "/url/to/dialog/content/including/layout/dijit/"
        });

在官方文件中检查此内容
或者试试这个:

this.scanDialog = new Dialog({
        title: dojoConfig.i18n.productCode,
        style: "width: 900px",
        showTitle:true,
        dimensions:[900,150],
        'class': 'dialogStyle',
          content:`<html>
<head>
    <meta charset="UTF-8">
    <title>Demo</title>
</head>
<body>
    <canvas width=500 height="240" id="canvas"></canvas>
    <hr>
   <input type="button" id="upload" value="upload" onclick="decodeLocalImage();">
    <ul></ul>
    <script type="text/javascript" src="filereader.js"></script>
    <script type="text/javascript" src="qrcodelib.js"></script>
    <script type="text/javascript" src="webcodecamjs.js"></script>
    <script type="text/javascript">

        var txt = "innerText" in HTMLElement.prototype ? "innerText" : "textContent";
        var arg = {
            resultFunction: function(result) {
                var aChild = document.createElement('li');
                aChild[txt] = result.format + ': ' + result.code;
                document.querySelector('body').appendChild(aChild);
            }
        };
        var decoder = new WebCodeCamJS("canvas").init(arg);

        function decodeLocalImage(){
            decoder.decodeLocalImage();
        }

    </script>
 </body>
 </html>` 
       });

相关问题