I’m trying to change the “continue shopping” link on Shopify’s “thank you” page but it doesn’t work.
I’ve included the following code to the additional scripts section on checkout page settings.
<script>
(function() {
document.getElementsByClassName("step__footer__continue-btn")[0].href = "https://example.com/newlink";
})();
</script>
Unfortunately, the node collection returned by the line below is always empty.
document.getElementsByClassName("step__footer__continue-btn")
The HTML part on the thank you page looks like this:
<a href="https://example.com/" data-trekkie-id="continue_shopping_button" class="step__footer__continue-btn btn">
<span class="btn__content">Continue shopping</span>
<svg class="icon-svg icon-svg--size-18 btn__spinner icon-svg--spinner-button" aria-hidden="true" focusable="false"> <use xlink:href="#spinner-button" /> </svg>
</a>
2
Answers
It is working for me
This is most likely because your JavaScript is loading before your HTML. There are two simple ways to fix this:
1: Place your
<script>
tags immediately before your closing</body>
tag like so:2: Place all your JavaScript code within a
window.onload
block: