javascript - 如何重定向 Google 协作平台上的 URL

标签 javascript html web google-sites sites

好的,我有一个 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/

相关文章:

javascript - 在不使用 `map` 两次的情况下将对象的属性收集到两个数组中的更简洁的方法?

带有 .Ajax()/childNodes 的 Javascript 选择器

javascript - 异步加载特定 CSS,并在加载时删除等待消息

linux - 将 Linux 服务器配置为 Web 服务器

javascript - 几秒钟后转到下一页

html - golang 中是否有 boilerpipe?

javascript - 从 JavaScript 中的自定义语法创建 AST

javascript - 如何获取 Bluebird Promise.settle() 的 promise 值?

html - 如何在我的网站上创建垂直线?

javascript - 当有人直接打开页面时如何进行基于 token 的身份验证