强制目标="_ self";在iframe中的动态外部跨域上 [英] force target="_self" on dynamic external cross domain in iframe

查看:143
本文介绍了强制目标="_ self";在iframe中的动态外部跨域上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用iframe在chrome上的信息亭模式下拥有一个网站,其中我正在打开多个外部网站.每个站点都有与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.

这属于同源策略,因此无法在客户端上解决.您可以在服务器上抓取这些站点,然后将它们显示为自己的站点,但是我不确定这样做的效果如何.

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.

这篇关于强制目标="_ self";在iframe中的动态外部跨域上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆