【发布时间】:2014-04-23 09:14:38
【问题描述】:
好的,我有一个需要重定向到网站的 Google 站点。
例如,我有sites.google.com/xxx/xxx
当人们进入时,我希望它重定向到我的网站
www.xxxxxxxx.com
我该怎么做?
【问题讨论】:
标签: javascript html web google-sites sites
好的,我有一个需要重定向到网站的 Google 站点。
例如,我有sites.google.com/xxx/xxx
当人们进入时,我希望它重定向到我的网站
www.xxxxxxxx.com
我该怎么做?
【问题讨论】:
标签: javascript html web google-sites sites
您可以通过使用 js 更改某些隐藏元素的 href 并使用 javascript “单击”该元素来绕过此问题。 我已经使用它直接在网站上创建联系人搜索元素。
标记
<a href="" id="searchHelper"></a>
<button onclick="functionSearch()" id="buttonSearch">
<input type="text" id="inputSearch" value="" placeholder="Search">
Javascript
function functionSearch() {
var inputSearch = document.getElementById("inputSearch");
if (inputSearch.value != "") {
document.getElementById("searchHelper").href = "https://contacts.google.com/search/" + inputSearch.value;
document.getElementById("searchHelper").click();
}
}
【讨论】:
在应用脚本上这是不可能的。
在 App Script 中,您可以这样做:
var anchor = app.createAnchor("link", "http://www.google.com");
查看文档: => https://developers.google.com/apps-script/reference/ui/anchor
在 JavaScript 上:
// click on a link
window.location.href = "http://google.com";
// redirect
window.location.replace("http://google.com");
【讨论】: