【问题标题】:Cannot get jQuery alerts to work in Google Apps script无法让 jQuery 警报在 Google Apps 脚本中工作
【发布时间】:2015-12-22 06:40:50
【问题描述】:

我无法让 jQuery 警报在我的 GAS 项目中工作。我可以像这样包含基本的 jquery 库:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>

但是,如果我尝试包含这些以使用 jAlert:

<script src="https://jquery.alerts.js" type="text/javascript"></script>
<link href="https://jquery.alerts.css" rel="stylesheet" type="text/css">

我在控制台中收到一条错误消息:“net::ERR_NAME_NOT_RESOLVED”。

如何包含用于 GAS 的 jquery 警报库?

注意:jquery.alerts.js 网站是否处于活动状态?我在那里看不到任何内容(我是新手。我不知道这个网站是否应该存在)。

【问题讨论】:

  • 您需要将文件 jquery.alerts.js 和 .css 保存到 https 网络服务器。 Google 协作平台或 Dropbox 能够托管文件。
  • 嗨。谢谢回复。有您知道的任何公共托管的 jquery 警报文件吗?我想既然这是一个常用的库,它可以很容易地在一些公共网络服务器上使用。
  • jQueryUI(已经包含)内置了对话框功能:jqueryui.com/dialog

标签: jquery google-apps-script


【解决方案1】:

您可以在您的谷歌应用脚​​本项目中添加 jquery.alerts 源。 在 Google Apps 脚本项目中创建 html 文件 jquery.alerts.css.html 并将源代码放入标签 style 中,例如

<style> popup_container { font-family: Arial, sans-serif; font-size: 12px; min-width: 300px; /* Dialog will be no smaller than this */ /*...and other code*/ </style>

比创建 html 文件 jquery.alerts.js.html 并将源代码放入标签 script 中,如

<script type="text/javascript"> (function($) {
$.alerts = { verticalOffset: -75, horizontalOffset: 0, repositionOnResize: true, /*...and other code*/ </script>

然后你什么时候可以使用这个库和 html 服务。示例:

<html> <?!= include('jquery.alerts.css.html'); ?> <?!= include('jquery.alerts.js.html'); ?> <head> <base target="_top"> </head> <body> <div> <a href="http://google.com">Click Me!</a> </div> </body> </html>

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-12-15
  • 1970-01-01
  • 2019-09-22
  • 1970-01-01
  • 2014-04-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多