好的,我有一个Google网站,我需要重定向到一个网站。
例如,我有sites.google.com/xxx/xxx
当人们输入时,我希望它重定向到我的网站
www.xxxxxxxx.com
我该怎么做?
答案 0 :(得分:1)
您可以使用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();
}
}
答案 1 :(得分:0)
在App脚本上,它是不可能的。
在App Script中,您可以这样做:
var anchor = app.createAnchor("link", "http://www.google.com");
查看文档: =&GT; 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");
答案 2 :(得分:-1)