2013-05-13 59 views
0

我在我的google网站中创建了一个简单的应用程序脚本小工具,它使用HtmlService生成输出。在源文件中,有一条土简单的超级链接HtmlService生成的脚本小工具:超链接不起作用

<a href="http://www.google.com">Link</a>

当我点击它,我得到在调试窗口的一份报告:

The page at https://sites.google.com/macros/s/AKfycbzw0jd06fDrbZ-KkjKmDvPKma_RZnboxe0iX…U6mS841TC3C&bc=transparent&f=Aclonica,sans-serif&tc=%23cccccc&lc=%23336699 displayed insecure content from http://google.com/. exec:1

The page at https://sites.google.com/macros/s/AKfycbzw0jd06fDrbZ-KkjKmDvPKma_RZnboxe0iX…U6mS841TC3C&bc=transparent&f=Aclonica,sans-serif&tc=%23cccccc&lc=%23336699 displayed insecure content from http://www.google.com/. exec:1

Refused to display 'https://www.google.com/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'. exec:1

任何想法如何解决这个问题?

回答

1

您要做的是在嵌入Google网站的Apps脚本小工具中打开google.com。如错误消息所示,X-Frame-Options不允许这样做。 所以,你应该目标属性添加到您<a>标签中打开一个新的或父窗口

例如,

<a href="http://www.google.com" target="_parent">Link</a> 

<a href="http://www.google.com" target="_blank">Link</a> 
+0

为目标=“_父母”我get:'https://sites.google.com/macros/s/AKfycbzw0jd06fDrbZ-KkjKmDvPKma_RZnboxe0iX...TykLqS3y8xm&bc=transparent&f=Aclonica,sans-serif&tc=%23cccccc&lc=%23336699中的页面显示来自http://www.google.com的不安全内容.com/.' '拒绝在框架中显示'https://www.google.com/',因为它将'X-Frame-Options'设置为'SAMEORIGIN'。对于target =“_ blank”,“ – Piotr 2013-05-13 16:40:54

+0

”似乎配合得当。谢谢! – Piotr 2013-05-13 16:42:20

+0

部分问题还在于我在JS中以编程方式执行此操作,显然您必须在“a”元素上使用'a.setAttribute(“target”,“_ blank”)'。我试图做'a.target =“_ blank”' – Piotr 2013-05-13 16:48:15