2015-12-22 47 views
3

我無法讓jQuery警報在我的GAS項目中工作。我能夠包括基本jQuery庫是這樣的:無法讓jQuery警報在Google Apps腳本中工作

<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"> 

我得到一個錯誤說:「網:: ERR_NAME_NOT_RESOLVED」在控制檯中。

如何包含用於GAS的jquery警報庫?

注意:jquery.alerts.js網站是否有效?我沒有看到任何內容(我是新手,我不知道這個網站是否應該存在或不存在)。

+1

您需要將文件jquery.alerts.js和.css保存到Web服務器的HTTPS。 Google協作平臺或Dropbox可以託管這些文件。 –

+0

嗨。謝謝回覆。有沒有公​​開的jquery警報文件,你知道嗎?我認爲,因爲這是一個常用的圖書館,它可以很容易地在一些公共網絡服務器上使用。 –

+0

jQueryUI(你已經包含)有內置的對話框功能:http://jqueryui.com/dialog/ –

回答

2

你可以在你的google apps腳本項目中添加jquery.alerts源代碼。 在谷歌的Apps腳本項目中創建的HTML文件jquery.alerts.css.html,並把它的源代碼在標籤風格

<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 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>

+1

做到了這一點,工作得很好,謝謝! (其他用戶請注意:您必須從文件創建模板輸出,並使用google apps server include詳細信息:https://developers.google.com/apps-script/guides/html/best-practices) –

相關問題