Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.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 chrome Google脚本数据Uri下载未自动初始化_Google Chrome_Google Apps Script_Href_Data Uri - Fatal编程技术网

Google chrome Google脚本数据Uri下载未自动初始化

Google chrome Google脚本数据Uri下载未自动初始化,google-chrome,google-apps-script,href,data-uri,Google Chrome,Google Apps Script,Href,Data Uri,我正试图在我们公司终端的Chrome浏览器上,在我的谷歌工作表中设置一个href链接(dataUri)。 下面的代码在我的个人电脑Chrome浏览器上运行良好,但在公司浏览器中不起作用 我使用了用户TheMaster在以下链接中看到的代码: 公司Chrome浏览器版本:版本83.0.4103.61(官方版本)(64位) 问题是,自动下载没有初始化。按左键时,可单击链接不起作用,但可以通过右键单击“保存在”保存PDF 是否有任何设置需要更改以使自动下载正常工作 多谢各位 function dow

我正试图在我们公司终端的Chrome浏览器上,在我的谷歌工作表中设置一个href链接(dataUri)。 下面的代码在我的个人电脑Chrome浏览器上运行良好,但在公司浏览器中不起作用

我使用了用户TheMaster在以下链接中看到的代码:

公司Chrome浏览器版本:版本83.0.4103.61(官方版本)(64位)

问题是,自动下载没有初始化。按左键时,可单击链接不起作用,但可以通过右键单击“保存在”保存PDF

是否有任何设置需要更改以使自动下载正常工作

多谢各位

function downloadPdfToDesktop() {
  var ss = SpreadsheetApp.getActive(),
    id = ss.getId(),
    sht = ss.getActiveSheet(),
    shtId = sht.getSheetId(),
    url =
      'https://docs.google.com/spreadsheets/d/' +
      id +
      '/export' +
      '?format=pdf&gid=' +
      shtId;
  var val = 'PDFNAME';//custom pdf name here 
  val += '.pdf';
  //can't download with a different filename directly from server
  //download and remove content-disposition header and serve as a dataURI
  //Use anchor tag's download attribute to provide a custom filename
  var res = UrlFetchApp.fetch(url, {
    headers: { Authorization: 'Bearer ' + ScriptApp.getOAuthToken() },
  });
  SpreadsheetApp.getUi().showModelessDialog(
    HtmlService.createHtmlOutput(
      '<a target ="_blank" download="' +
        val +
        '" href = "data:application/pdf;base64,' +
        Utilities.base64Encode(res.getContent()) +
        '">Click here</a> to download, if download did not start automatically' +
        '<script> \
        var a = document.querySelector("a"); \
        a.addEventListener("click",()=>{setTimeout(google.script.host.close,10)}); \
        a.click(); \
        </script>'
    ).setHeight(50),
    'Downloading PDF..'
  );
}
函数下载pdftodesktop(){
var ss=SpreadsheetApp.getActive(),
id=ss.getId(),
sht=ss.getActiveSheet(),
shtId=sht.getSheetId(),
网址=
'https://docs.google.com/spreadsheets/d/' +
身份证+
“/导出”+
“?格式=pdf&gid=”+
shtId;
var val='PDFNAME';//此处为自定义pdf名称
val+='.pdf';
//无法使用其他文件名直接从服务器下载
//下载并删除内容处置标头并用作dataURI
//使用锚定标记的下载属性提供自定义文件名
var res=UrlFetchApp.fetch(url{
标头:{授权:'承载'+ScriptApp.getOAuthToken()},
});
SpreadsheetApp.getUi().showModelessDialog(
HtmlService.createHtmlOutput(
'下载,如果下载未自动启动'+
' \
var a=文件查询选择器(“a”)\
a、 addEventListener(“单击”,()=>{setTimeout(google.script.host.close,10)})\
a、 单击()\
'
).设置高度(50),
“下载PDF…”
);
}

是否可能阻止了此页面的弹出窗口?target=“\u blank”必须被某些浏览器明确允许。您好,罗玛,谢谢您的输入。我没有收到那种弹出窗口。有没有办法通过一些特定的设置使弹出窗口变绿?谢谢。另外,请检查“浏览器开发控制台”中的错误。禁用弹出窗口可能是公司的政策。按照
检查默认设置,弹出窗口设置被授予。空白表单弹出窗口也工作,只是陈述。PDF的下载尚未初始化。自动或左键单击“单击此处”按钮。开发控制台显示:Error code=10,Path=/wardeninit,name:“TransportError”如果脚本是在单元格中执行的,而不是在按钮中执行,则会显示:[……]错误代码401[…]使用muteHttpExceptions选项检查完整响应是否可能阻止了此页面的弹出窗口?target=“\u blank”必须被某些浏览器明确允许。您好,罗玛,谢谢您的输入。我没有收到那种弹出窗口。有没有办法通过一些特定的设置使弹出窗口变绿?谢谢。另外,请检查“浏览器开发控制台”中的错误。禁用弹出窗口可能是公司的政策。按照
检查默认设置,弹出窗口设置被授予。空白表单弹出窗口也工作,只是陈述。PDF的下载尚未初始化。自动或左键单击“单击此处”按钮。开发控制台显示:Error code=10,Path=/wardeninit,name:“TransportError”,如果脚本是在单元格中执行的,而不是在按钮中执行,则会显示:[……]错误代码401[…]使用muteHttpExceptions选项检查完整响应