Search code examples
htmlbuttoninputtarget

Input button target="_blank" isn't causing the link to load in a new window/tab


I have an HTML file with an input button. This is only an example button, but it's including all necessary info of code:

<input type="button" onClick="parent.location='http://www.facebook.com/'" value="facebook" target="_blank">

For some reason, it's not loading in a new window/tab.


Solution

  • you will need to do it like this...

    <a type="button" href="http://www.facebook.com/" value="facebook" target="_blank" class="button"></a>
    

    and add the basic css if you want it to look like a btn.. like this

        .button {
        width:100px;
        height:50px;
        -moz-box-shadow:inset 0 1px 0 0 #fff;
        -webkit-box-shadow:inset 0 1px 0 0 #fff;
        box-shadow:inset 0 1px 0 0 #fff;
        background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ffffff), color-stop(1, #d1d1d1) );
        background:-moz-linear-gradient( center top, #ffffff 5%, #d1d1d1 100% );
     filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#d1d1d1');
        background-color:#fff;
        -moz-border-radius:6px;
        -webkit-border-radius:6px;
        border-radius:6px;
        border:1px solid #dcdcdc;
        display:inline-block;
        color:#777;
        font-family:Helvetica;
        font-size:15px;
        font-weight:700;
        padding:6px 24px;
        text-decoration:none;
        text-shadow:1px 1px 0 #fff
    }
    
    
    
      .button:hover {
        background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #d1d1d1), color-stop(1, #ffffff) );
        background:-moz-linear-gradient( center top, #d1d1d1 5%, #ffffff 100% );
     filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#d1d1d1', endColorstr='#ffffff');
        background-color:#d1d1d1
    }
    .button:active {
        position:relative;
        top:1px
    }
    

    target works only with href tags..