Reputation: 1
I have a button in menu section with link to pop-up. I want to make so that it was opened in the same tab.
Here is the code of this button:
<button
class="btn btn-bg-no btn-border-green btn-color-green hvr hvr-buzz-out"
onclick="window.open('<?php echo esc_url( $menu_btn_url ); ?>', '_blank')">
<?php echo esc_html( $menu_btn ); ?>
</button>
I was trying to change '_blank'
to '_self'
. It changes the url, but my pop-up didn't appear. What can I do?
Upvotes: 0
Views: 384
Reputation: 13840
If you look at the docs for window.open() you'll see the second parameter is actually for naming the window if it doesn't reference an existing context, and webkit (chrome) has been having issues for the longest time with this.
You mention the button triggers a pop-up, but _self
would basically treat it like you're clicking on a standard link, no? You may be better off using a standard link:
<a class="btn btn-bg-no btn-border-green btn-color-green hvr hvr-buzz-out" href="<?php echo esc_url( $menu_btn_url ); ?>">
<?php echo esc_html( $menu_btn ); ?>
</a>
If for some reason you want an onclick
event, you'd probably be better suited using window.location.href
instead of window.open
:
<button class="btn btn-bg-no btn-border-green btn-color-green hvr hvr-buzz-out" onclick="window.location.href = '<?php echo esc_url( $menu_btn_url ); ?>'">
<?php echo esc_html( $menu_btn ); ?>
</button>
Also, a side note your SSL certificate on your website isn't working as it's issued to
auditerra.ru
and notintererka.auditerra.ru
or*.auditerra.ru
Upvotes: 1