Button link doesn't work in Firefox, IE

后端 未结 5 817
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-20 20:51

I have links inside of that work fine in Chrome, but not IE or Firefox. Nothing happens if you click on them. I\'ve messed with the CSS (z-index included), but am out of i

相关标签:
5条回答
  • 2020-12-20 21:10

    I had a similar situation and posted my question here => Why does Dreamweaver cc16, Bootstrap v3.3.6, created, hyperlinked Button work in Opera & Chrome but not IE or Firefox?

    Here is my original code for a Button =>

    The Button html code is: =>
    

    <div align="center" style="font-size: 1.5em"> <button type="button" class="btn btn-lg"> <a href="https://howtoliveoffthegridnow.com/wordpress/get-your-own-off-the-grid-checklist/" title="Access option to download checklist"><strong>FREE: 11 Things To Know Before Going Off The Grid</strong></a> </button> </div>

    and the relevant bootstrap.css v3.3.6 is linked conventionally using: =>

    <link rel="stylesheet" type="text/css" href="assets/css/bootstrap.css" />

    That worked in Chrome and Opera but not IE or Firefox though, apparently, it should not have worked in any browser.

    Here is what I changed that Button code element into =>

    `<div class="btn btn-lg" style="background-color:#ffffff;">
     <a href="https://howtoliveoffthegridnow.com/wordpress/get-your-own-off-the-grid-checklist/" title="Access option to download checklist"><strong>FREE: 11 Things To Know Before Going Off The Grid</strong></a>
    

    That works across all browser. /psb

    0 讨论(0)
  • 2020-12-20 21:14

    <button> isn't being used right.

    HTML:

     <div class="product-display-block-link">
        <button onClick="javascript: window.location='/checkout/outfield-banner/1'">Add to Cart</button>
    </div>
    

    See it in action here: http://jsfiddle.net/s8jtf/

    0 讨论(0)
  • 2020-12-20 21:18

    Also, type attribute is missing. Different browsers assume different type, for example, not necessarily type="submit".

    0 讨论(0)
  • 2020-12-20 21:27

    The HMTL syntax does not allow an a element within a button element, so it is not surprising that it does not work across browsers. There should be no reason to use such a construct, since you can either style a link to look like a button or associate an action with a button, depending on what you wish to accomplish.

    0 讨论(0)
  • 2020-12-20 21:29

    If you want a button (i.e. a thing to submit a form with or dangle JavaScript from), use a button. If you want a link, use a link. If you want a link that looks like a button, use a link then style it to look the way you want.

    You can't mix the two because <button> elements aren't allowed to contain <a> elements. The definition of the element explicitly excludes them:

    <!--
     Content is %Flow; excluding a, form and form controls
    --> 
    <!ELEMENT button %button.content;>  <!-- push button -->
    
    <!ENTITY % button.content
       "(#PCDATA | p | %heading; | div | %lists; | %blocktext; |
        table | %special; | %fontstyle; | %phrase; | %misc;)*">
    
    0 讨论(0)
提交回复
热议问题