问题描述
我在Chrome上使用iframe在kiosk模式上有一个网站,其中我打开了外部网站的数量。并且每个站点都有自己的target =_ blank链接。我无法控制这些外部链接。
我想只打开iframe中的所有外部链接,或者我需要为那些target = _blank链接发布一些消息。我无法在自助服务终端上打开新窗口。我到目前为止已经搜索过,发现它必须是一些服务器端编码。 Javascript对此没有任何帮助。
I have a site on kiosk mode on chrome using iframe in which I am opening number of external sites. And each of the sites has their own links with target="_blank". I have no control on those external links.I want to open all those external links inside iframe only or I would need to publish some message for those target=_blank links. I can't open new window on kiosk. I have searched so far and found it has to be some server side coding. Javascript won't be any help in that.
我的iframe代码:
My iframe code:
navigateToExternal:function(href)
{
Engine.ui.openMenu();
Engine.ui.exit();
Engine.ui.mostRecentSection = "external";
$("a[data-navsection], a[href]").removeClass("disabled");
$("a[href='" + href + "']").addClass("disabled");
$(".footer").hide();
var sandbox = "sandbox=\"allow-forms allow-scripts allow-same-origin\"";
$("#content-container").append("<iframe id=\"contentFrame\" src=" + href + "\"" + sandbox + "></iframe>");
},
任何帮助或建议真的很棒。
Any help or suggestion would be really great.
提前致谢!!
推荐答案
您不能,父页面无法访问跨网站iframe,iframe无法访问跨网站的父网页。
You can't, the parent page can't access the cross-site iframe and the iframe can't access the cross-site parent page.
这属于Same-Origin策略并不能在客户端进行解决。你可以在服务器上抓取这些网站并将它们作为你自己的网站展示,但是我不确定它会有多么有效。
This falls under the Same-Origin policy and can't be worked-around on the client-side. You could scrape those sites on the server and present them as your own, however I'm not sure how effective that will be.
这篇关于force target =" _self" iframe中动态extrnal跨域的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!