0

Note: I want my link to open in a new tab, but keep it where the original tab stays in place. However the original tab is leading to somewhere different?

        .btn {
            background-color: transparent;
            border-radius: 28px;
            border: 1px solid #0762C8;
            display: inline-block;
            cursor: pointer;
            color: #0762C8;
            font-family: Tahoma;
            font-size: 14px;
            padding: 4px 13px;
            text-decoration: none;
            position: absolute;
            margin-top: -10%;
        }
    
        .btn:hover {
            background-color: #0762C8;
            border-color: #0762C8;
        }
    
        .btn:active {
            position: relative;
            top: 1px;
        }
    
        .flex-container {
            display: flex;
            justify-content: center;
        }
    <div class="col-12 col-md-6 col-lg-4 py-3 text-center border"><a
                        href="http://www.example.net/" target="_blank"
                        ><img class="img-fluid" font-family:lucida="" sans=""
                            src="/images/contentimages/images/Giveaways.png" /></a>
    
                    <p class="my-3" style="font-size:18px;">&nbsp;</p>
    
                    <div class="flex-container"><a class="btn btn-info btn-sm edatalayer order-1" onclick=" window.open('http://www.example.net/','_blank')"
                            data-list="product-listing-page" data-position="1" data-purl="custom-business-forms"
                            >Giveaways <i class="far fa-chevron-right pl-1"></i></a></div>
                </div>
zoldxk
  • 2,632
  • 1
  • 7
  • 29
nik_avp
  • 25
  • 6
  • 1
    Does this answer your question? [Open link in new tab or window](https://stackoverflow.com/questions/15551779/open-link-in-new-tab-or-window) – zoldxk May 06 '21 at 22:00

3 Answers3

1

You can do it using onclick:

<a href="https://example.com" onclick="window.open('#','_blank');window.open(this.href,'_self');">
zoldxk
  • 2,632
  • 1
  • 7
  • 29
  • That works, however it opens the original tab in a new tab. Is there a way to keep the original page in the original tab and then open the link in the new tab? – nik_avp May 06 '21 at 23:24
0

You need to consider using target="_self". See https://www.w3schools.com/tags/att_a_target.asp for more info.

1BL1ZZARD
  • 225
  • 2
  • 14
0

Instead of directly adding the link, you could use the window.open function in javascript:

<a href="javascript:window.open('https://example.com')">
<img class="img-fluid" font-family:lucida="" sans="" src="/images/contentimages/images/Giveaways.png" />
</a>
Jake
  • 97
  • 1
  • 9