xyz*_*xyz 2 javascript clipboard web-applications modal-dialog google-apps-script
当我单击按钮时,我已将格式化数据添加到模态对话框中
showModalDialog()我希望当我单击按钮时将的内容自动添加到剪贴板
模态是使用下面的代码生成的,并且temp是我想要添加到剪贴板的输出
//Output to Html
var htmlOutput = HtmlService
.createHtmlOutput(temp)
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setWidth(600)
.setHeight(500);
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'Filter OptionList Maker');
Run Code Online (Sandbox Code Playgroud)
编辑; 好吧,我想也许这可能Modal Dialog是题外话,正确的问题可能是如何将格式化的字符串添加temp到剪贴板
这是我所说的格式化字符串的示例
filter {
target: element;
as: dropdown;
padding: 5;
summary: "Network Practice";
default: show-all;
multiple: true;
option {
label: "< 1 year";
selector: element["NETWORK PRACTICE"="< 1 year"];
}
option {
label: "1-3 years";
selector: element["NETWORK PRACTICE"="1-3 years"];
}
option {
label: "3-10 years";
selector: element["NETWORK PRACTICE"="3-10 years"];
}
option {
label: "> 10 years";
selector: element["NETWORK PRACTICE"=">10 years"];
}
}
Run Code Online (Sandbox Code Playgroud)
我已经搜索过如何执行此操作,但没有找到解决方案
谢谢
您可以在 html 中创建一个textareahtml 并使用 html 中的按钮将其中的数据复制到剪贴板。
<textarea id="copy"><?=temp?></textarea>
<button>Copy</button>
<script type="text/javascript">
let t = document.getElementById('copy');
let copy = () => {
t.select();
document.execCommand('copy');
};
copy();//try copying without user click
let bt = document.querySelector('button');
bt.addEventListener('click', copy);
</script>
Run Code Online (Sandbox Code Playgroud)
//Output to Html
var template = HtmlService.createTemplateFromFile('copy');
template.temp = temp;
var htmlOutput = template.evaluate();
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'Filter OptionList Maker');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1540 次 |
| 最近记录: |