好的,所以我有一个需要重定向到网站的 Google 站点。例如,我有sites.google.com/xxx/xxx
当人们输入它时,我希望它重定向到我的网站
www.xxxxxxxx.com
我该怎么做呢?
好的,所以我有一个需要重定向到网站的 Google 站点。例如,我有sites.google.com/xxx/xxx
当人们输入它时,我希望它重定向到我的网站
www.xxxxxxxx.com
我该怎么做呢?
您可以通过使用 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 上是不可能的。
在 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");