2017-04-12 35 views
-1

は、私が代わりに新しい空のウィンドウの同じウィンドウにACFフィールドから渡されたURLを開くためのボタンが必要ですが、このボタンのonclick機能をのonClickオープンURL

<input type="button" class="cta-button" value="<?php the_field('button-text'); ?>" onclick="window.open('<?php the_field('button-link'); ?>')"> 

お困り私はそれを働かせるために苦労しています。代わりに、あなたはonclick="window.open('<?php the_field('button-link'); ?>', '_self')"を使用することができますwindow.open使用window.location.href

<input type="button" class="cta-button" value="<?php the_field('button-text'); ?>" onclick="window.location.href = '<?php the_field('button-link'); ?>'"> 
+0

入力ボタンにする必要がありますか? 代わりにアンカーリンクはどうですか?

答えて

0

使用windows.location

<input type="button" class="cta-button" value="<?php the_field('button-text'); ?>" onclick="window.location = '<?php the_field('button-link'); ?>'"> 
1

_selfを指定すると、新しいウィンドウを開くのではなく、現在のウィンドウでリンクが開きます。

0

を使用しての

関連する問題