简体   繁体   English

如何在Facebook标签的新窗口中打开iframe?

[英]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. 预订掩码将在Facebook页面上的iFrame中使用。

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. 目前,我正在使用window.top.location.href打开新窗口。 This works to break out of the iframe, but not to open a new tab/window. 这可以打破iframe的作用,但不能打开新的标签页/窗口。

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 在下面的代码中使用iFrame的ID

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM