[英]Loading HTML file contents into dojo dialog
我想將 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 文件加載到對話框中?
您可以使用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>`
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.