好的,我有一个 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();
}
}
关于javascript - 如何重定向 Google 协作平台上的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23239837/