【问题标题】:how to give a href inside the button tag in html如何在html中的按钮标签内给出href
【发布时间】:2012-01-13 07:31:34
【问题描述】:

当在 html 页面中单击一个按钮时,我需要打开两个链接。我认为它是通过调用 onclick 函数并使用 Javascript 中的 createElement 创建锚标记。但是如何包含另一个链接?有没有办法在按钮标签中给出一个href??

【问题讨论】:

    标签: javascript html


    【解决方案1】:

    你可以简单地用 javascript 做到这一点

    window.open(url1);
    window.open(url2);
    

    如果你想在当前窗口中打开其中一个链接,你可以用这个替换 window.open

    window.location = url1;
    

    【讨论】:

      【解决方案2】:
        <input type="button" value="Double Clicker"  onclick="window.open(&quot;http://www.google.com/&quot;); window.open(&quot;http://www.youtube.com/&quot;);" />
      

      更多信息请参见this link

      【讨论】:

        【解决方案3】:

        您需要使用 javascript 事件来使页面转到某个地方

        <input type="button" name="button1" value="Go To Url" onClick="window.navigate('URL')"> 
        

        【讨论】:

          【解决方案4】:

          你也可以使用

          location.href=" ";`
          

          【讨论】:

            【解决方案5】:

            试试看位置对象能做什么 => http://www.w3schools.com/jsref/obj_location.asp 您应该能够加载两个选项卡。

            【讨论】:

              【解决方案6】:

              你为什么不使用引导程序

               <a href="#" class="btn btn-default">
              

              它显示一个带有链接的按钮,链接到 href 中提到的内容

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 2013-01-12
                • 2012-02-07
                • 2019-10-17
                • 1970-01-01
                • 1970-01-01
                • 2015-08-06
                • 1970-01-01
                • 1970-01-01
                相关资源
                最近更新 更多