var clickTag = "https://www.example.com"; var clickTag = "https://www.example.com"; var clickTag = "https://www.example.com";

javascript:window.open(window.clickTag) opens double tabs in Firefox

15.6k Views Asked by At

I am using clickTags in my code for tracking. This is my setup.

<script type="text/javascript">
    var clickTag = "https://www.example.com";
</script>

<a href="javascript:window.open(window.clickTag)">
---Content---
</a>

The issue is with Firefox opening double tabs when I click on the link. I only want it to open to the information that is associated with the link. My question, is there a workaround or is there a bug with Firefox?

2

There are 2 best solutions below

1
Edward Newsome On

For this i would create a function (see below)

<script type="text/javascript">
    function clickTag() {
    return "http://example.com"
    }
</script>

<a href="#" onclick="window.open(clickTag()); return false;">Link</a>

https://jsfiddle.net/3kdcyrbe/

0
user11113491 On

javascript:window.open(window.clickTag) was what i got from coding from my website and then copying it after it finilized. :)