<button id="OrderNumber">Open Link</button>
<script>
const apiUrl = 'https://luxeurs-com.myshopify.com/admin/orders.json?name=51153';
// Get a reference to the button element using its ID
const button = document.getElementById('OrderNumber');
button.addEventListener('click', () => {
fetch(apiUrl)
.then(response => response.text())
.then("tracking_url" => {
// Use the window.open() method to open the link in a new window
window.open("tracking_url", '_blank');
})
.catch(error => {
// Handle any errors that occur during the fetch operation
console.error(error);
});
});
</script>
<script>
const apiUrl = 'https://luxeurs-com.myshopify.com/admin/orders.json?name=51153';
// Get a reference to the button element using its ID
const button = document.getElementById('OrderNumber');
button.addEventListener('click', () => {
fetch(apiUrl)
.then(response => response.text())
.then("tracking_url" => {
// Use the window.open() method to open the link in a new window
window.open("tracking_url", '_blank');
})
.catch(error => {
// Handle any errors that occur during the fetch operation
console.error(error);
});
});
</script>