开发者

How to open an iframe in a new window in a Facebook Tab?

  • I´m developing a simple form that allows users to check availability in a hotel for specific dates.
  • When a user clicks the "Book Now" button, a new page will load (the booking engine) showing the availability.
  • The booking mask will be used within an iFrame on a Facebook Page.

I´d like to load the new page in a new browser window/tab (depending on the user´s settings).

At the moment I´m using window.top.location.href to open the new window. This works to break out of the iframe, but not to open a new tab/window.

Do you have any suggestions?

This is the code I´m using in it´s most basic form:

// The event: 
<开发者_开发知识库input type="button" value="Book now" onClick="do_action();" />

// The function: 
function do_action() {
  baseURL = "http://www.bookingengine.com;"
  var1 = "parameter1;"
  var2 = "parameter2;"
  var3 = "parameter3;"
  window.top.location.href = baseURL+ var1 + var2 + var3; 
}


Just had the same issue, can´t believe I didn´t think of this solution when I asked this question. Anyway, for future reference here´s how to open a new window (following the above example):

 window.open(baseURL+var1+var2+var3) 


Use the ID of the iFrame in the code below

frame=document.getElementById("YourFrameIDHere");
frame.document.location.href="http://www.bookingengine.com";
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜