Reputation: 177
I am working on a shopping cart project, and I am using simplecart framework. I am a complete beginner at javascript.
The html:
<a class="item_add" href="javascript:;">Add to Cart</a>
Basically I would like the href to go to a checkout page for example checkout.html, but the href already has "javascript:;" value for the add the cart function, is there a way of adding to the below that it redirects or directs to checkout.html after adding to cart, I have tried a few things with no avail.
The Js:
{ selector: 'shelfItem .item_add'
, event: 'click'
, callback: function () {
var $button = simpleCart.$(this),
fields = {};
... if statements
}
// add the item
simpleCart.add(fields);
}
So after the simpleCart.add(fields); is there a way to make it go to another page.
Any help would be great!
Thanks!
Upvotes: 0
Views: 267
Reputation: 556
If you're completly done and you think you can safely start a redirect, you can easily do it by changing the href property like this:
window.location.href = 'http://your-url.com';
This will start a redirect to your-url.com but might also cut off scripts which are not finished yet.
Upvotes: 1