在模态框 Google 脚本中为 Textarea 赋予尺寸
Give dimensions to Textarea in a modal box Google script
我正在尝试为模式框中的文本区域指定尺寸。
从这里开始
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>
我可以为模态指定尺寸
//Output to Html
var template = HtmlService.createTemplateFromFile('copy');
template.temp = temp;
var htmlOutput = template.evaluate();
htmlOutput.setWidth(610)
htmlOutput.setHeight(500);
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'OptionList Multiple Selectors');
}
我正在尝试让 Modal 和 Textarea 的尺寸相同
现在的文本区域大约是 20 x 50。
试试这个:
<textarea id="copy" cols="20" rows="50"><?=temp?></textarea>
您也可以尝试使用 JavaScript 进行设置:
<textarea id="copy"><?=temp?></textarea>
<button style="width:100%">Copy</button>
<script type="text/javascript">
let t = document.getElementById('copy');
t.style.height = t.scrollHeight + "px";//or 100%
t.style.width = "100%"
let copy = () => {
t.select();
document.execCommand('copy');
};
/*copy();//try copying without user click */
let bt = document.querySelector('button');
bt.addEventListener('click', copy);
</script>
<textarea id="copy">
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"];
}
}
</textarea>
<button style="width:100%">Copy</button>
<script type="text/javascript">
let t = document.getElementById('copy');
t.style.height = t.scrollHeight +"px";//or 100%
t.style.width = "100%"
let copy = () => {
t.select();
document.execCommand('copy');
};
/*copy();//try copying without user click */
let bt = document.querySelector('button');
bt.addEventListener('click', copy);
</script>
参考文献:
- RelatedQ:Resize text area
- textarea
我正在尝试为模式框中的文本区域指定尺寸。
从这里开始
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>
我可以为模态指定尺寸
//Output to Html
var template = HtmlService.createTemplateFromFile('copy');
template.temp = temp;
var htmlOutput = template.evaluate();
htmlOutput.setWidth(610)
htmlOutput.setHeight(500);
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'OptionList Multiple Selectors');
}
我正在尝试让 Modal 和 Textarea 的尺寸相同 现在的文本区域大约是 20 x 50。
试试这个:
<textarea id="copy" cols="20" rows="50"><?=temp?></textarea>
您也可以尝试使用 JavaScript 进行设置:
<textarea id="copy"><?=temp?></textarea>
<button style="width:100%">Copy</button>
<script type="text/javascript">
let t = document.getElementById('copy');
t.style.height = t.scrollHeight + "px";//or 100%
t.style.width = "100%"
let copy = () => {
t.select();
document.execCommand('copy');
};
/*copy();//try copying without user click */
let bt = document.querySelector('button');
bt.addEventListener('click', copy);
</script>
<textarea id="copy">
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"];
}
}
</textarea>
<button style="width:100%">Copy</button>
<script type="text/javascript">
let t = document.getElementById('copy');
t.style.height = t.scrollHeight +"px";//or 100%
t.style.width = "100%"
let copy = () => {
t.select();
document.execCommand('copy');
};
/*copy();//try copying without user click */
let bt = document.querySelector('button');
bt.addEventListener('click', copy);
</script>
参考文献:
- RelatedQ:Resize text area
- textarea