• Resolved Uriahs Victor

    (@uriahs-victor)


    If I use this code:

    <p style="text-align: center;"><a class="button" href="/newsletter" target="_blank" rel="noopener">[boxzilla-close]Yes Please![/boxzilla-close]</a></p>

    then it messes up the button style

    If I use this code instead:

    <p style="text-align: center;">[boxzilla-close]<a class="button" href="/newsletter" target="_blank" rel="noopener">Yes Please!</a>[/boxzilla-close]</p>

    It just doesn’t close the box when the button is clicked.

    If I use this code:

    <p style="text-align: center;"><a href="/newsletter" target="_blank" rel="noopener">[boxzilla-close]Yes Please![/boxzilla-close]</a></p>

    Then it just closes the box without opening a new tab with the link specified in the href

    Ideally what I’m trying to do is display the box on mobile in the center of the screen. When a user clicks “Yes Please!” it would open a new window leading to the newsletter page while closing the box at the same time, so when they come back to the window they were…the box would be gone. The plugin doesn’t seem to be able to make a clickable link also act as a close trigger

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Lap

    (@lapzor)

    The shortcode will already generate the <A href= code for you, so it should not be wrapped in another A tag nor should there be an A tag inside the shortcode.

    Just [boxzilla-close]Yes Please![/boxzilla-close] without any firther code should do.

    You can also use <a href="Boxzilla.close(5);">Close box</a>, assuming box ID is 5.

    Hope that helps. If you have any questions, please let us know!

    • This reply was modified 8 years ago by Lap.
    Thread Starter Uriahs Victor

    (@uriahs-victor)

    @lapzor how do I make a link which opens a new window while closing the box on the current page where it was clicked?

    Plugin Contributor Lap

    (@lapzor)

    I guess you could do something like this:

    Boxzilla.on('box.dismiss', function(box) {
       window.open("https://www.mc4wp.com");
    });

    This javascript code will fire any time the box is closed.
    You can use the normal [boxzilla-close]Yes Please![/boxzilla-close] to close the box.

    https://kb.boxzillaplugin.com/javascript-events/

    Hope that helps. If you have any questions, please let us know!

    Thread Starter Uriahs Victor

    (@uriahs-victor)

    Was able to get close:

    Boxzilla.on('box.dismiss', function(box) {
    if( box.id == 1849 ){
    window.open('https://www.mc4wp.com');
    }
    });

    The only issue is that it still opens the link even though the user chooses to use the X in the top right because of course that fires dismiss as well

    The reason I’m trying to accomplish this is that the form I want to put in the “box” is pretty long and I don’t want mobile users to be inconvenienced by it. I want them to say “Yes” and if so a new page opens with the form and closes the box at the same time so they can come back(hopefully) to the old page and continue reading.

    Currently it would still have the box open if they come back to the old window

    Maybe add another event to the plugin that lets us be able to do this?

    Plugin Contributor Lap

    (@lapzor)

    How about:

    <a href="Boxzilla.close(5);window.open('https://www.mc4wp.com');">open link</a>

    Please note that custom Javascript like this is out of scope for our free support, from here on I suggest to hire a professional coder if you need more help. Hope you understand.

    Hope that helps.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Can’t wrap close shortcode around links’ is closed to new replies.