• Resolved d2earth

    (@d2earth)


    Regarding your post in the FAQ section:
    “How to open external links in a new popup window?”

    Could you please tell me where I should add the JavaScript code. Thank you.

    By adding this JavaScript code to your site:

    jQuery(function ($) {
    $(‘a[data-wpel-link=”external”]’).click(function (e) {
    // open link in popup window
    window.open($(this).attr(‘href’), ‘_blank’, ‘width=800, height=600’);

    // stop default and other behaviour
    e.preventDefault();
    e.stopImmediatePropagation();
    });
    });

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter d2earth

    (@d2earth)

    Sorted.
    I added an HTML widget to the page I needed this to function on.
    Then it’s important to add <script> and </script> before and after.

    <script>
    jQuery(function ($) {
    $(‘a[data-wpel-link=”external”]’).click(function (e) {
    // open link in popup window
    window.open($(this).attr(‘href’), ‘_blank’, ‘width=800, height=600’);

    // stop default and other behaviour
    e.preventDefault();
    e.stopImmediatePropagation();
    });
    });
    </script>

    Plugin Author Alexandru Tapuleasa

    (@talextech)

    Hi,

    Yes, that should work! ??
    Happy to hear you managed to set it up.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Where to add JavaScript code?’ is closed to new replies.