简体   繁体   English

设置仅重定向网址,而不是在iFrame上

[英]Set Redirect of only URL, not at iFrame

I am wondering if I can set a redirect at a URL (This part can be done easily I know v). 我想知道是否可以在URL上设置重定向(我知道v可以很容易地完成这一部分)。

But this redirect ONLY actually redirects, when the URL is visited. 但是, 仅当访问URL时,此重定向才实际重定向。 Not when the URL is displayed within an iFrame . 在iFrame中显示URL时不可以

Can this be done at all? 可以做到吗? Essentially; 实质上; Visit said URL with redirect implemented in the header; 通过标头中实现的重定向访问所述URL; web page redirects to the defined. 网页重定向到已定义。 BUT, a website using that said URL within a iFrame call, it does not redirect. 但是,在iFrame调用中使用该URL的网站不会重定向。

Basically a page via URL only really accessible & viewable via an iFrame call. 基本上,通过URL的页面只能通过iFrame调用真正访问和查看。

This is possible via client-side. 这可以通过客户端进行。 If you add following code to page onload event: 如果将以下代码添加到页面onload事件:

if (location.href == top.location.href) location.href='http://your_new_url';

the page will redirect to new URL only if it is called as top-level page. 该页面在被称为顶级页面时才会重定向到新URL。 If it is called within an IFRAME - the condition will be false and redirect will not happen. 如果在IFRAME中调用它-条件将为false,并且不会发生重定向。

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

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