好的,所以我有一个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">


Java脚本

      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();
        }
      }

08-25 19:50