简体   繁体   English

Google Apps脚本中的IFRAME和NATIVE模式

[英]IFRAME and NATIVE Mode in Google Apps Script

I have created a google apps script to display some indicators with images. 我创建了一个Google Apps脚本来显示一些带有图像的指示器。 I have used the following code function doGet() { var output= HtmlService.createHtmlOutputFromFile('cfcgfcg'); 我已经使用以下代码函数doGet(){var output = HtmlService.createHtmlOutputFromFile('cfcgfcg'); output.setSandboxMode(HtmlService.SandboxMode.IFRAME); output.setSandboxMode(HtmlService.SandboxMode.IFRAME); return output; 返回输出; } The code works fine in NATIVE mode, but it does not work with IFRAME mode. }该代码在NATIVE模式下可以正常工作,但在IFRAME模式下不能正常工作。 I have tried the guidlines to migrate from NATIVE to IFRAME given in the following link https://developers.google.com/apps-script/migration/iframe#setting_the_link_target_attribute 我已经尝试了以下链接https://developers.google.com/apps-script/migration/iframe#setting_the_link_target_attribute中给出的从NATIVE迁移到IFRAME的指南

But the code doesn't work 但是代码不起作用

Following is the code I have used https://drive.google.com/open?id=1C9_tabVhPq1NhKBjqNATvdC5G9542A8rRqhxpa-BSknx8m19Kts6bsB- 以下是我使用过的代码https://drive.google.com/open?id=1C9_tabVhPq1NhKBjqNATvdC5G9542A8rRqhxpa-BSknx8m19Kts6bsB-

it seems that you used a wrong url to load JQuery lib, Use console to see the error messages using this one hosted on https server works in IFRAME mode : 似乎您使用了错误的URL来加载JQuery库,使用控制台查看使用HTTPS服务器上托管的该URL的错误消息在IFRAME模式下有效:

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://apis.google.com/js/api.js?onload=onApiLoad"></script>

Check if it runs on load by adding a log for example 通过添加日志来检查它是否在负载下运行

function update() {
    console.log("update executed");
    $.ajaxSetup({ cache: false });
    var data=google.script.run.withSuccessHandler(onSuccess).getMyData();
    window.setTimeout(update, 500);
}
update();

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

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