ReferenceError:“文档"没有定义 [英] ReferenceError: "document" is not defined
问题描述
我不熟悉JavaScript,甚至更不熟悉Google Apps脚本.我正在尝试一个简单的函数来显示当前日期(仅日,月e和整年),但是Google脚本显示错误ReferenceError:未定义文档".
Im new to JavaScript and even more new to Google Apps Script. Im trying a simple function that shows the current date (only day, month e and full year), but the Google Script show the error ReferenceError: "document" is not defined.
我的目标是在Google网站中使用此功能.这是代码:
My goal is to use this function in a Google Site. Here is the code:
function Data()
{
var d=new Date();
var dia=d.getDate();
var mes=d.getMonth();
var ano=d.getFullYear();
var DataCompleta=dia + "/" + mes + "/" + ano
document.write(DataCompleta);
}
推荐答案
如前一个答案中所述,您不能直接在浏览器中执行功能,则必须选择一个所谓的'文档,然后尝试一些
As said in the former answer you can't execute a function directly in the Browser, you'll have to choose a so called 'container' to run your function from it. I would recommand you read the documentation and maybe try a few simple tutorials to see how GAS can be executed.
:发表您的评论后,请随时查看并显示您想要的内容:您好,今天是2012年10月25日"
EDIT : following your comments, feel free to have a look at this script built with UiApp, the result is viewable here and shows what you wanted to : "Hello, today is 25/10/2012"
这篇关于ReferenceError:“文档"没有定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!