title: Close Fancybox 2 window and redirect parent window
body: <p>I've got a Fancybox 2 iframe modal window that contains an 'Add to Cart' form. When the form is submitted, a success/confirmation page will be loaded within the Fancybox modal window.</p>
  
  <p>I want to run a script on this success/confirmation page that closes the Fancybox window and redirects the parent window to this URL: '/shop/basket' How can I do this?</p>
  
  <p>Here's the code I've got at the moment (which just closes the Fancybox window, but doesn't do the parent window redirect):</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    $(function() { parent.$.fancybox.close(); });
  &lt;/script&gt;
  </code></pre>
  
  <p>Edit:</p>
  
  <p>This is how I initialise the Fancybox within my functions.js file:</p>
  
  <pre><code>$(".add-to-cart-popup").fancybox({
      width       : 580,
      height      : 744,
      closeClick  : false,
      scrolling   : 'auto'
  });
  </code></pre>
  
  <p>Edit 2:</p>
  
  <p>This code does what I'm looking for - but can anyone think of any better ways of doing this? This is just something I've hacked together:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    $(function() { parent.$.fancybox.close(); });
    window.parent.location.href = '/shop/basket';
  &lt;/script&gt;
  </code></pre>