【问题标题】:How to Redirect URL on Google Sites如何在 Google 网站上重定向 URL
【发布时间】:2014-04-23 09:14:38
【问题描述】:

好的,我有一个需要重定向到网站的 Google 站点。 例如,我有sites.google.com/xxx/xxx 当人们进入时,我希望它重定向到我的网站

www.xxxxxxxx.com

我该怎么做?

【问题讨论】:

    标签: javascript html web google-sites sites


    【解决方案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();
            }
          }
    

    【讨论】:

    • 这对我在浏览器中的应用程序不起作用。 =\
    【解决方案2】:

    在应用脚本上这是不可能的。

    在 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");
    

    【讨论】:

      猜你喜欢
      • 2017-04-13
      • 2017-02-04
      • 2018-07-30
      • 1970-01-01
      • 1970-01-01
      • 2021-10-20
      • 1970-01-01
      • 2017-08-10
      • 1970-01-01
      相关资源
      最近更新 更多