[英]How to open an iframe in a new window in a Facebook Tab?
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.