开发者

Javascript: Change form target, redirect existing iframe

I'm have an instance where I'm using a Shopify store as a Facebook iframe app. Works great, except that the embedded https is problematic. I need to pop a new window, only when they're in Facebook (as they can also hit the ecommerce store directly), for the checkout process so that the user doesn't see a mismatched security error message. I have this working on the submit button's onclick by calling the following:

  function changeTarget() {
    //test to determine if facebook iForm
    if(location.href != top.location.href){ 
      $("#cartform").attr("target", "_blank");
      // **** need to redirect the iframe to the front page of the shopping cart here ****
    }
  }

The last piece I need is to redirect the iFrame back to a specific page. I don't want the users to complete their purchase, close the new window, and see their cart sitting there.

The Facebook iframe has an id of "iframe_canvas" and looks like this:

<iframe class="smart_sizing_iframe" frameborder="0" scrolling="yes" id="iframe_canvas" name="iframe_canvas_fb_https" src='javascript:""' height="600px" style="height: 514px; "></iframe&g开发者_如何学Got;

I've tried adding:

top.iframe_canvas.location.href="http://foo.org/";

and...

self.location.href="http://foo.org/";

Neither worked. Ideas?


self.location.replace(""http://foo.org/") ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜