IFRAME和Google Apps脚本中的NATIVE模式 [英] IFRAME and NATIVE Mode in Google Apps Script

查看:86
本文介绍了IFRAME和Google Apps脚本中的NATIVE模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个Google应用程序脚本来显示图片的一些指标。
我已经使用了下面的代码
函数doGet(){
var output = HtmlService.createHtmlOutputFromFile('cfcgfcg');
output.setSandboxMode(HtmlService.SandboxMode.IFRAME);
返回输出;
}
NATIVE模式下的代码工作正常,但它不适用于IFRAME模式。我试图将指导从NATIVE迁移到IFRAME,如以下链接所示:
https://developers.google.com/apps-script/migration/iframe#setting_the_link_target_attribute

I have created a google apps script to display some indicators with images. I have used the following code function doGet() { var output= HtmlService.createHtmlOutputFromFile('cfcgfcg'); output.setSandboxMode(HtmlService.SandboxMode.IFRAME); return output; } The code works fine in NATIVE mode, but it does not work with IFRAME mode. 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://drive.google.com/open?id=1C9_tabVhPq1NhKBjqNATvdC5G9542A8rRqhxpa-BSknx8m19Kts6bsB-

Following is the code I have used https://drive.google.com/open?id=1C9_tabVhPq1NhKBjqNATvdC5G9542A8rRqhxpa-BSknx8m19Kts6bsB-

推荐答案

它似乎你使用了错误的URL来加载JQuery库,使用控制台查看错误消息
使用托管在https服务器上的错误消息在 IFRAME 模式下工作:

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 :

<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();

这篇关于IFRAME和Google Apps脚本中的NATIVE模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆