html - 如何提供一个简单的静态 html 页面并使用提供的位置哈希
问题描述
我想提供一个页面并使用提供的位置哈希,以便页面向下滚动到正确的位置。由于 Google App Scripts 将输出放入包含的 iframe 中,因此顶部浏览器窗口中的哈希将被忽略。
我的 doGet() 看起来像这样:
function doGet(e) {
return HtmlService.createHtmlOutput(DriveApp.getFilesByName('My File.html').next().getBlob().getDataAsString());
}
这有效并且页面加载。这是一个完全静态的页面,在页面访问时不会生成任何内容。如果我缺少从 Google Drive 提供静态 html 文件的简单方法,请告诉我。现在我希望页面向下滚动到页面上的指定位置。网址看起来像
http://bit(dot)ly/myspecialwebpage#some-subject
这将重定向到类似的东西
https://script.google.com/macros/s/AK...Hckf/exec#some-subject
我尝试将此脚本放入 html 中,但它不起作用
<script>
window.onload = function() {
window.location.hash = window.top.location.hash
</script>
顶部窗口由 script.google.com 提供
并且 iframe 由 script.googleusercontent.com 提供
解决方案
推荐阅读
- git - git push 出错 [致命:远程端意外挂断]
- javascript - 如何从 sessionStorage 中检索多个选择值并将它们放入原始表单字段中
- java - 如何使用 java spring boot 应用程序中的 SQL CONTAINS 查询 Cosmos DB 图?
- elasticsearch - 如果出现则必须与关键字匹配文档,如果关键字不出现则必须匹配其他文档
- python - 预定消息删除后仍在发送
- java - java.lang.NoClassDefFoundError:来自 Keycloak 的 java/security/acl/Group
- javascript - 允许用户将项目添加到上下文菜单 - chrome 扩展
- javascript - 从 Node.js Telegram Bot 中的另一个文件打印输出
- amp-html - AMP 网络代理专家
- typescript - 如何在 Vue3(Composition API) 中正确导入 Monaco IStandaloneCodeEditor 接口