Javascript + popup shortcodes wordpress

Right now I am using a javascript to trigger a new tab and load a new page in the parent window. It looks like this:

 <script type="text/javascript">
    function openOtherLinks(id1, id2) {
    var link1 = document.getElementById(id1);
    var link2 = document.getElementById(id2);
    if(!link1.href || !link2.href)
    return;
    window.open(link2.href);
    document.location.replace(link1.href);
    }
</script>
<a href="javascript:openOtherLinks('link1', 'link2')"><img class="aligncenter size-medium wp-image-94" src="x" alt="x" width="200" height="43"/></a>
<a id="link1" href="url1"></a><br/>
<a id="link2" href="url2" target="_blank">`

This triggers the “same” page in a new tab on click (works fine).
The problem is that I want to trigger a popup on click, I´ve tried several plugins for pop-ups without any success. Is it even possible to trigger a popup after loading the page in a new tab?

Read More

The pop-up im talking about is a pop-up for that very link. It is going to show a coupon code. Therefore I can not trigger the pop-up on a specific url since the url/page contains several campaigns with different coupon codes.

I´ve seen this type of solution in multiple webpages but can´t figure out how
they´ve done it. The easiest solution would be to simply add a popup #id in the end of the url to trigger the popup but I haven´t found any plugin that works this way.

btw, im talking about “in page popups”. Not a new window.

Related posts