【问题标题】:Button works in Firefox but not in Chrome按钮在 Firefox 中有效,但在 Chrome 中无效
【发布时间】:2015-06-11 19:08:14
【问题描述】:

所以我对 HTML 一无所知,我正在编辑我的网站

我设法创建了一个打开链接的按钮

<button onclick="location.href = 'http://gotlinks.co/5Vvl';" id="myButton" class="float-left submit-button" >Click me to Verify!</button>

但它只适用于firefox而不适用于chrome,请有人帮助我

【问题讨论】:

  • 查看&lt;a&gt; 标签
  • 我不会帮你用谷歌搜索的......你可以自己做。
  • 同样在 chrome 中,当它不起作用时,它只是将它添加到 url "?#" 的末尾

标签: html google-chrome firefox button hyperlink


【解决方案1】:

改用 window.location.href

<button onclick="window.location.href = 'http://gotlinks.co/5Vvl';" id="myButton" class="float-left submit-button" >Click me to Verify!</button>

【讨论】:

【解决方案2】:

试试这个基本代码。

 <button onclick="myFunction()" id="myButton" class="float-left
         submit-button" >Click me to Verify!</button>

         <script> 
             function myFunction() {
                  window.location.href = "http://gotlinks.co/5Vvl"; 
             } 
         </script>

【讨论】:

  • 好吧,我真的很高兴,因为它在 chrome 中工作,但现在如果我在 Firefox 中访问该站点,它会立即将我重定向到该链接,在 Firefox 中测试它“thegemgenerator.com”
  • 是的,看起来一样@trkh
  • 如果不一样,请在函数 myFunction 中尝试这个
  • 改成这个和同样的问题
猜你喜欢
  • 2016-02-19
  • 2022-01-23
  • 1970-01-01
  • 2023-03-27
  • 2020-04-04
  • 2011-03-16
  • 2018-07-05
  • 2014-08-18
  • 2016-07-01
相关资源
最近更新 更多