Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 在谷歌电子表格中点击一个按钮并在新标签中将其重定向到一个URL后,该按钮的脚本会发出警报吗?_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 在谷歌电子表格中点击一个按钮并在新标签中将其重定向到一个URL后,该按钮的脚本会发出警报吗?

Google apps script 在谷歌电子表格中点击一个按钮并在新标签中将其重定向到一个URL后,该按钮的脚本会发出警报吗?,google-apps-script,google-sheets,Google Apps Script,Google Sheets,我试图在google电子表格中添加一个按钮,将用户重定向到脚本中指定的特定URL。这是我正在使用的脚本: function testNew() { showURL('Search Here','https://docs.google.com'); } // function showURL(name,url) { var html = '<html><body><a href="'+url+'" target="parent" onclick="

我试图在google电子表格中添加一个按钮,将用户重定向到脚本中指定的特定URL。这是我正在使用的脚本:

function testNew() {
    showURL('Search Here','https://docs.google.com');
}
//


function showURL(name,url) {
    var html = '<html><body><a href="'+url+'" target="parent" onclick="google.script.host.close()">'+name+'</a></body></html>';
    var ui = HtmlService.createHtmlOutput(html).setHeight(50).setWidth(200)
    var ui = SpreadsheetApp.getUi();
    var response = ui.alert('Confirm', 'Are you sure you want to continue?', ui.ButtonSet.YES_NO) ;
}

if (response = ui.Button.YES) {
    openURL(name,url)

}
else {
    Logger.log("You should have tried")
}
然后警报框工作得很好,但当我点击“是”时,什么也没发生。它不会将我重定向到任何地方。

您将获得“
ui未检测到”
”,因为您已在函数
showURL

if (response = ui.Button.YES){
  openURL(name,url)
}else {
  Logger.log("You should have tried")
}
如果您想重新指向不同的页面,请参阅下面的代码

function testNew(){
  showURL('Search Here','https://docs.google.com');
}

function showURL(name,url) {
    var html = '<html><body style="margin:0px;"><div class="modal-dialog-buttons"><a href="'+url+'" target="parent" onclick="google.script.host.close()"><button style="margin:5px;">Yes</button></a><button onclick="google.script.host.close()">No</button></div></body></html>';
    var ui = HtmlService.createHtmlOutput(html).setHeight(50).setWidth(400)
    SpreadsheetApp.getUi().showModalDialog(ui, 'Are you sre you want to contine?');
 }
函数testNew(){
showURL('在此处搜索','https://docs.google.com');
}
函数showURL(名称、url){
var html='否';
var ui=HtmlService.createHtmlOutput(html).setHeight(50).setWidth(400)
SpreadsheetApp.getUi().showModalDialog(用户界面“您想继续吗?”);
}
function testNew(){
  showURL('Search Here','https://docs.google.com');
}

function showURL(name,url) {
    var html = '<html><body style="margin:0px;"><div class="modal-dialog-buttons"><a href="'+url+'" target="parent" onclick="google.script.host.close()"><button style="margin:5px;">Yes</button></a><button onclick="google.script.host.close()">No</button></div></body></html>';
    var ui = HtmlService.createHtmlOutput(html).setHeight(50).setWidth(400)
    SpreadsheetApp.getUi().showModalDialog(ui, 'Are you sre you want to contine?');
 }