簡體   English   中英

按鈕網址在某些瀏覽器中不起作用

[英]Button URL not working in some browsers

我正在嘗試調用特定的帖子元數據(“購買門票”),以用作可點擊的按鈕。 該代碼在Safari中有效,但在其他瀏覽器中無效。 我正在使用最新版本的Wordpress。 以下是我當前正在使用的代碼:

<td>
<input type="button" value="Buy tickets"
onclick="window.open('<?php echo get_post_meta(get_the_ID(), 'Buy tickets', true); ?>')">
</td>

我也嘗試使用以下腳本,但這會使按鈕不可點擊:

<td>
<button id="<?php $postId = get_the_ID(); echo $postId ?>" style="float:right">
<p>Buy tickets</p>
</button>
</td>


<script>
$(document).ready(function() {
// Handler for .ready() called.

$("#<?php $postId = get_the_ID(); echo $postId ?>").click(function(){
         window.location="<?php echo get_post_meta(get_the_ID(), 'Buy tickets', true); ?>"
         return false;
    });

    });
</script>

任何建議將不勝感激! 要查看運行中的第一段代碼,請單擊此處

<form onsubmit="return false;">
<table class="tickets">
<tr>
    <td><button data-goto="<?php echo get_post_meta(get_the_ID(), 'Buy tickets', true); ? >">Buy tickets</button></td>
</tr>
</table>
</form>

<script>
jQuery(document).ready(function($) {
$("table.tickets button").click(function(event) {
    window.location.href = $(this).attr("data-goto");
});
});
</script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM