我已经搜索了很多论坛并且非常有信心这将是一个不,但我想我会向社区开放以防万一;)
我的任务是在我们的 Google 协作平台页面上创建一个工具,用于记录我们员工在访问页面后的访问次数。它有助于确认文档访问和活动日志的合规性。如果 iFrame 与它所在的页面位于同一域中,则从框架内查询父页面的 URL 相当容易,但安全限制会限制跨域或子域的查询。
我希望我将 Google 应用程序脚本嵌入到 Google 网站页面这一事实会给我更多选择。到目前为止,我已经尝试了命令document.referrer、parent.document.location、parent.window.document.location、parent.window.location、parent.document.location.href,以及从窗口和文档的角度相同的命令。他们的回答都是一样的:
https://n-labp6vtqrpsdn12345neycmicqw7krolscvdkda-0lu-script.googleusercontent.com/userCodeAppPanel
Run Code Online (Sandbox Code Playgroud)
当我想要:
https://sites.google.com/mysite.com/mysite/test/test3
Run Code Online (Sandbox Code Playgroud)
有没有谷歌老手有额外的技巧?
编辑:我刚刚尝试通过 html 链接传递变量,Google 网站上的 Apps 脚本的 Google 图像占位符,并且稍微远了一点。你看,我可以运行这个 url:https : //script.google.com/a/macros/coordinationcentric.com/s/AKfycbxDX2OLs4LV3EWmo7F9KuSFRljMcvYz6dF0Nm0A2Q/exec? test = hello&test2=howareyou 如果我运行 url 并获取变量 test1 和 test2在一个单独的窗口中。如果我尝试将该 URL 嵌入到 Google 协作平台上的 HTML 页面中,则会引发此混合内容错误:
trog_edit__en.js:1544 Mixed Content: The page at
'https://sites.google.com/a/mysite.com/mysite/test/test3' was loaded over HTTPS, but requested an insecure image 'http://www.google.com/chart?chc=sites&cht=d&chdp=sites&chl=%5B%5BGoogle+Apps+Script%27%3D20%27f%5Cv%27a%5C%3D0%2710%27%3D499%270%27dim%27%5Cbox1%27b%5CF6F6F6%27fC%5CF6F6F6%27eC%5C0%27sk%27%5C%5B%22Apps+Script+Gadget%22%27%5D%27a%5CV%5C%3D12%27f%5C%5DV%5Cta%5C%3D10%27%3D0%27%3D500%27%3D197%27dim%27%5C%3D10%27%3D10%27%3D500%27%3D197%27vdim%27%5Cbox1%27b%5Cva%5CF6F6F6%27fC%5CC8C8C8%27eC%5C%27a%5C%5Do%5CLauto%27f%5C&sig=TbGPi2pnqyuhJ_BfSq_CO5U6FOI'. This content should also be served over HTTPS.
Run Code Online (Sandbox Code Playgroud)
有人尝试过这种方法吗?
我正在Google表格中创建一个菜单项,该菜单项将列出工作目录并提取该用户的电子邮件地址,以供以后在Google表格中处理员工记录。我正在尝试使其像这样工作:
function onOpen() {
var ui = SpreadsheetApp.getUi();
// Or DocumentApp or FormApp.
var myapp = ui.createMenu('MyApp');
var pullemp = myapp.addSubMenu(ui.createMenu('Pull Employee')
.addItem('Nathaniel MacIver', menuItem2('nm@emailaddress.com')));
myap.addToUi();
}
function menuItem2(email) {
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.alert('That email address is '+email);
}
Run Code Online (Sandbox Code Playgroud)
现在,当我打开电子表格时,该项目立即触发,并在下面得到我想要的结果:
但是我希望当我单击菜单中的按钮时触发它。照原样,当我单击菜单按钮时出现错误:
我知道该链接提到功能名称必须是一个字符串值,但是为什么它会按需要在加载时工作,然后在按下按钮时失败?
我使用Jquery创建了以下DOM:
<div id="d0" class="choiceDiv">
<input type="checkbox" id="cb0" class=".userCheckBox" value="Option 1" checked="checked">
<input type="hidden" id="h0" class=".userCheckBoxHidden" value="true">
<label for="cb0">Option 1</label>
</div>
Run Code Online (Sandbox Code Playgroud)
我已经将CSS标记应用于DOM中的元素,此时CSS类内部没有任何属性。
一个div中大约有17个。加载页面后,我想重新加载每个复选框的当前选中值。在遍历每个代码时,我尝试在DOM上使用.find()函数:
$('.choiceDiv').each(function(e){
Run Code Online (Sandbox Code Playgroud)
当我尝试按班级查找时,
$(this).find('.userCheckBox');
Run Code Online (Sandbox Code Playgroud)
我得到以下失败对象:
init [prevObject: init(1), context: div#d0.choiceDiv, selector: ".userCheckBox"]
context: div#d0.choiceDiv
length: 0
prevObject:init [div#d0.choiceDiv, context: div#d0.choiceDiv]
selector:".userCheckBox"
__proto__:Object(0)
Run Code Online (Sandbox Code Playgroud)
当我尝试按ID查找时,
$(this).find('#cb'+e)[0];
Run Code Online (Sandbox Code Playgroud)
我得到了我想要的东西:
<input type="checkbox" id="cb0" class=".userCheckBox" value="Option 1" checked="checked">
Run Code Online (Sandbox Code Playgroud)
我希望按类提取对象,以确保始终获得所需的输入类型。有人可以解释为什么我可以在此实例中使用带ID的.find()而不是按类使用吗?我试图通过这篇文章弄清楚它,但无法正常工作。