我正在try 在我的Angular项目中实现Dynamsoft Web Twain.但安装弹出窗口中没有关闭按钮.如何在弹出窗口中添加关闭按钮?
我的Angular 版本是13.3
我正在try 在我的Angular项目中实现Dynamsoft Web Twain.但安装弹出窗口中没有关闭按钮.如何在弹出窗口中添加关闭按钮?
我的Angular 版本是13.3
有三种方法可以在dynamsoft.webtwain.install.js
中添加关闭按钮:
将_this.DWT.ShowMessage(ObjString.join(''), { width: promptDlgWidth, headerStyle: 1, closeButton: true });
中的值closeButton
更改为true
.默认值为false
.
根据当前代码添加按钮元素.
例如,添加
ObjString.push('<div><a id="dwt-btn-close"
onclick="Dynamsoft.onClose()"><div class="dynamsoft-dwt-dlg-
button">Close</div></a></div>');
在下面
ObjString.push(' onclick="Dynamsoft.DCP_DWT_onclickInstallButton()">
<div class="dynamsoft-dwt-dlg-button">Download</div></a></div>');
然后添加按钮点击功能
Dynamsoft.onClose = function() {
document.getElementsByClassName('dynamsoft-dialog')
[0].style.display = 'none';
}
在上面
Dynamsoft.DCP_DWT_onclickInstallButton = function ()
现在,弹出窗口如下所示:
可以单击"关闭"按钮关闭对话框.由于为z-index
,弹出对话框下的HTML元素不可 Select .一个棘手的方法是在隐藏弹出对话框后修改z-index
:
let divs = document.getElementsByTagName('div');
for (let i = 0; i < divs.length; i++) {
divs[i].style.zIndex = -1;
}
不要打_this.DWT.ShowMessage(ObjString.join(''), { width: promptDlgWidth, headerStyle: 1, closeButton: true });
.相反,可以使用jQuery创建自定义对话框.例如:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Dialog - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js">
</script>
<script>
$( function() {
$( "#dialog" ).dialog();
} );
</script>
</head>
<body>
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying
information. The dialog window can be moved, resized and closed with
the 'x' icon.</p>
</div>
</body>
</html>