javascript - 上传到 Google 脚本 HTML 时,Google 脚本不显示 jQuery 布局

标签 javascript jquery html google-apps-script

在我的 html 编辑器上,此代码可以工作,但是当我使用用于 google 脚本的 Code.gs 上传它时。

function doGet() {
 return HtmlService.createHtmlOutputFromFile('hh');
 }

它应该显示与我的 html 编辑器中相同的布局,但看起来不同。您可以在这里看到它:

https://script.google.com/macros/s/AKfycbwM0y5y3kkgWAoPb99hXwdJKTpvt3hvXwWLHvzehbcw/dev

<title>jQuery Mobile</title>
    <meta name="viewport" content="width=device-width">
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
    <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>

    </script>
    <body>
       <!-- label text -->
       <div data-role="page">
          <div data-role="header" data-theme="a">
             <h1>Example</h1>
             <form id="form" name="form">
          </div>
          <div style="width:auto; margin:20px;padding-top:30px;">
          <label for="howMuch_1">How much?</label>
          <input id ="howMuch_1" type="range" min="1" max="100" value="1">
          <label for="howMany_1">How many tickets?</label>
          <input id ="howMany_1" type="range" min="1" max="50" value="1">
          <label for="lastNumber_1">Last number?</label>
          <input id ="lastNumber_1" type="range" max="700" min="1" value="1">
          <button id="add" ></button>
          </div>
          </form>
       </div>
</body>

最佳答案

我猜测 CAJA 已经清理并删除了 jQuery Mobile 的一些功能。但这只是一个猜测。尝试使用:

  return HtmlService.createTemplateFromFile('hh')
    .evaluate() // evaluate MUST come before setting the NATIVE mode
    .setTitle('Title of your app')
    .setSandboxMode(HtmlService.SandboxMode.NATIVE);

将沙盒模式设置为 NATIVE 可能会有所帮助,但我不能保证。

引用文献:

Google Caja

引用:

To protect users from being served malicious HTML or JavaScript, Apps Script relies on the Caja Compiler to sanitize and sandbox HTML-service web apps or custom user interfaces for Google Docs, Sheets, and Forms.

Apps Script HTML Service Restrictions

关于javascript - 上传到 Google 脚本 HTML 时,Google 脚本不显示 jQuery 布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24624016/

相关文章:

jquery - 缓存 JSON 响应

javascript - 将温度调整为 LAB 色彩空间

javascript - Phonegap - 如何下载文件

javascript - 箭头键在内容内不起作用可编辑

javascript - 防止 div 在 slideUp() 之后显示 - jQuery

html - 通过移动设备打开网站时将字符串移动到新段落

javascript - HTML5 输入类型范围 - 非线性序列?

javascript - js-data v3-将元信息保存在分页端点中

javascript - 如何在数组中存储唯一的函数名称

javascript - 我如何找出鼠标在 d3 中的 x 和 y 位置?