如何通过Google Apps Script为不同Google表格设置自定义Favicon
为Google Sheets添加自定义Favicon的原生方案
由于Google Sheets页面由Google托管,无法直接修改其内置favicon,但可以通过Google Apps Script创建Web App作为表格入口,实现自定义favicon需求,无需依赖浏览器扩展,在任意设备上均可生效。
实现步骤
- 打开目标Google Sheet,点击顶部菜单「扩展」>「Apps Script」进入脚本编辑器。
- 替换默认
Code.gs代码为以下内容:
function doGet() { // 替换为你的Google Sheet嵌入链接(需先发布表格为嵌入形式) const sheetEmbedUrl = "替换为你的表格嵌入URL"; // 替换为你的自定义图标URL const customFaviconUrl = "https://www.botix.com.ar/imagenes-empresa/favicon-pedidos.ico"; const htmlContent = HtmlService.createHtmlOutput(` <!DOCTYPE html> <html> <head> <link rel="icon" href="${customFaviconUrl}" type="image/x-icon"> <title>自定义表格标题</title> <style> html, body { margin: 0; padding: 0; height: 100vh; overflow: hidden; } iframe { width: 100%; height: 100%; border: none; } </style> </head> <body> <iframe src="${sheetEmbedUrl}"></iframe> </body> </html> `); return htmlContent.setFaviconUrl(customFaviconUrl); }
- 获取表格嵌入URL:
- 返回Google Sheet,点击「文件」>「共享」>「发布到网络」
- 选择「嵌入」选项,设置发布范围后点击「发布」,复制生成的嵌入链接替换代码中的
sheetEmbedUrl
- 部署Web App:
- 在脚本编辑器点击「部署」>「新部署」
- 选择部署类型为「Web App」,设置「执行权限」为「我自己」(按需调整),「谁可以访问」对应设置为「任何人」或「仅限组织内用户」
- 点击「部署」,复制生成的Web App链接
- 后续直接访问该Web App链接,标签页将显示自定义favicon,页面内完整加载Google Sheet内容。
注意事项
- 确保自定义图标URL为公开可访问状态,否则Web App无法加载图标
- 若Google Sheet设置了访问权限,需保证Web App的访问权限与表格权限匹配,避免加载失败
内容的提问来源于stack exchange,提问作者Agustina Botas May
相关产品推荐
相关产品推荐

