简体   繁体   English

如何从跨源站点中的谷歌应用程序脚本 webapp 访问相机?

[英]How to access camera from google apps script webapp framed in a cross origin site?

I have a iframe on my page.我的页面上有一个 iframe。 The iframe src is a google webapp with src="https://script.google.com/macros/s/.......". iframe src 是一个带有 src="https://script.google.com/macros/s/......" 的 google webapp。

That page is a form and it works with camera and geolocalisation.该页面是一种形式,它适用于相机和地理定位。 My problem is, when I directly access the form without framing, it works perfectly, but when I frame the apps script web app, the form works but camera and geo doesn't.我的问题是,当我在没有框架的情况下直接访问表单时,它工作得很好,但是当我框架应用程序脚本 web 应用程序时,表单有效但相机和地理区域没有。

I mean: if I use https://script.google.com/macros/s/... .我的意思是:如果我使用https://script.google.com/macros/s/... the form works perfect, but if I use iframe on my web page, the camera and geo no work!该表格工作完美,但如果我在我的 web 页面上使用 iframe,则相机和地理坐标不起作用! <iframe src="https://script.google.com/macros/s/......."></iframe> I tried adding allow="camera; microphone and another attributes but still no work it. <iframe src="https://script.google.com/macros/s/......."></iframe>我尝试添加allow="camera; microphone和其他属性,但仍然没有用。

How can I solve that?我该如何解决?

here my link iframe: iframe allow="camera *; microphone *" src="https://script.google.com/macros/s/AKfycbzsaOlh4Gp2EJmdyQ9cvkYmezTCsg_9wd6ILjdwTe6MRgNBDitcE5Hijr2sNeBknMvp/exec" width="750" height="1100" frameborder="0" marginheight="0" marginwidth="0" id="cultos" name="cultos">/iframe这是我的链接 iframe: iframe allow="camera *; microphone *" src="https://script.google.com/macros/s/AKfycbzsaOlh4Gp2EJmdyQ9cvkYmezTCsg_9wd6ILjdwTe6MRgNBDitcE5Hijr2sNeBknMvp15"frame="0borderMvp15" " marginheight="0" marginwidth="0" id="cultos" name="cultos">/iframe

link script https://script.google.com/macros/s/AKfycbzsaOlh4Gp2EJmdyQ9cvkYmezTCsg_9wd6ILjdwTe6MRgNBDitcE5Hijr2sNeBknMvp/exec note: link script work 100% but on iframe no work camera and geolocalitation链接脚本https://script.google.com/macros/s/AKfycbzsaOlh4Gp2EJmdyQ9cvkYmezTCsg_9wd6ILjdwTe6MRgNBDitcE5Hijr2sNeBknMvp/exec注意:链接脚本工作 100% 但在 iframe 没有工作的地理相机和定位

Since Google apps script web app is a nested iframe with different origins , you might need to add a specific allowlist along with allow .由于 Google 应用程序脚本 web 应用程序是嵌套的 iframe,来源不同,您可能需要添加特定的allowlist以及allow . . This is because the default allow 's allowlist defaults to src .这是因为默认allowallowlist默认为src Thus it won't allow nested cross origin iframes.因此,它不允许嵌套的跨源 iframe。 Try尝试

<iframe src="https://script.google.com/macros/s/......." 
        allow="camera https://[SCRIPT_ID].googleusercontent.com"></iframe>

Here, SCRIPT_ID can be found by examining the "#1 Outer sandbox iframe" html structure according to the structure here .这里SCRIPT_ID可以根据这里的结构查看“#1 Outer sandbox iframe”html结构体找到。 Alternatively and less securely, you can allow all origins using * ,或者,安全性较低,您可以使用*允许所有来源,

<iframe src="https://script.google.com/macros/s/......." 
        allow="camera *"></iframe>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM