I want to run javascript on specific URL load, below is my code. It only shows an alert on the home page, not on the URL I have a condition on i.e. https://www.example.com/cart it gives an alert message on the home page only.
<script type="text/javascript">
var currURL = window.location.href;
function codeAddress() {
if (currURL = 'https://www.example.com/cart'){
alert('We are not shipping to countries that are not listed in shipping country!');
}
}
window.onload = codeAddress;
</script>
Aucun commentaire:
Enregistrer un commentaire