使用javascript阻止在iframe中制作的页面 [英] Pages using javascript to prevent making it in iframe

查看:75
本文介绍了使用javascript阻止在iframe中制作的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一些页面不允许将其放入iframe代码

i意味着如果你把这个页面放在iframe中这样:

there's some pages that doesn't allow to put it in iframe code
i mean if you put that page in iframe like this:

<iframe src="PAGE LINK HERE"></iframe>



它会将你从包含iframe的整个页面重定向到另一个网站

代码是如下所示:


and it will redirect you from whole page that has iframe to another website
the code is like this below :

<script type="text/javascript">
    function substr_count(string,substring,start,length)
    {
     var c = 0;
     if(start) { string = string.substr(start); }
     if(length) { string = string.substr(0,length); }
     for (var i=0;i<string.length;i++)
     {
      if(substring == string.substr(i,substring.length))
      c++;
     }
     return c;
    }
    var topdom = document.referrer.split('/')[2];
    var mydomain = "undefined,website1.com,website2.com,website3.com,website4.com";
    if(substr_count(mydomain,topdom)==0){
    top.location = "http://www.website.com";
    }
    </script>



是否有任何方法可以使用Javascript或PHP或其他任何东西禁用该页面上的代码把那个页面放在iframe中?


is there any way to disable that code on that page using Javascript or PHP or anything to allow me to put that page in iframe?

推荐答案

当然,做你想做的事在技术上是完全可能的,尽管有点棘手。



但首先,让我解释一下,从道德理由开始,这可能是一个非常可疑的步骤,甚至可以合法挑战



让我们理解为什么要包含的页面的作者(我将其称为 remote页面下面框架决定阻止这种使用。作者的方法也可以被认为是有问题的,但该人有权施加这种限制。页面的内容确实有一定的作者。也许作者想要将此内容的所有权与她/他自己的网站,她/他的公司或他/她关联的其他组织相关联。通过常规引用,可以在浏览器的地址行中清楚地指出作者的网站。可能还有其他一些原因;例如:页面可能不适合在框架中显示。



现在,让我们看看你在框架中展示这个远程页面的含义是什么,不尊重作者对我上述限制的写作。也许,您不能保证您的框架周围有明确显示内容归属的信息。您以一些常规查看器(不使用查看页面源查看HTML源代码)的方式显示内容会让人觉得内容属于您的网站。



这类似于 hotlinking 甚至抄袭。不要误会我的意思:我并不是说你要进行抄袭,但你的行为会有一些特点。剽窃者歪曲了一些信息:这样的人讲述了一些内容的作者。根据其真实作者的意愿或合同,您将代表内容与网站的关联。



最后:从技术上讲,您可以通过复制实现这一点您网站上的远程页面,并链接您框架中的副本。要克服关注的限制(重定向),您需要修改页面内容:删除重定向脚本。但是,这并不是那么简单:由于页面位置的改变,您需要修改其中的大部分或全部链接(基本上,转换为绝对URL)。同样,请记住此类行为可以在道德上或甚至在法律上受到挑战。更好不要这样做。只需引用该页面,用户就可以正常查看。 尊重远程内容作者的意图。



-SA
Of course, doing what you want is technically quite possible, albeit a bit tricky.

But first of all, let me explain that this can be quite a questionable step of you, from the ethical grounds, and can be even challenged legally.

Let's understand why the author of the page you wanted to include (I'll refer to it as to "remote page" below) in the frame decided to prevent such use. The author's approach can also be considered questionable, but that person had every right to impose such limitation. The content of the page does have certain author. Maybe the author wanted to associate the ownership of this content with her/his own site, her/his company or other organization he/she associated with. With a regular reference, the author's Web site would be clearly indicated in the address line of the browser. There could be some other reasons; for example: the page could be not designed for showing in the frame.

Now, let's see what would be the implication of your presentation of this remote page in a frame, without respecting author's write for the limitations I described above. Probably, you don't guarantee that you surround your frame with information clearly showing the attribution of the content. You show the content the way some regular viewer (not looking at you HTML source using "View Page Source") would have the impression that the content belongs to your site.

This resembles hotlinking and even plagiarism. Don't get me wrong: I am not saying you are going to perform plagiarism, but your action would have some features of it. A plagiarist misrepresent some information: such person tells lies about the author of some content. You would represent affiliation of the content with the Web site, against the will or contract of its real author.

And, finally: technically, you could achieve that by copying the remote page on your site and linking the copy in your frame. To overcome the limitation of concern (redirection), you would need to modify the page content: remove the redirection script. However, this is not so simple: due to change of location of the page, you would need to modify most or all links in it (basically, convert to absolute URLs). Again, remember that such action on your side can be ethically or even legally challenged. Better don't do it. Simply reference the page, so the users will view it normally. Respect the intend of the author of the remote content.

—SA

这篇关于使用javascript阻止在iframe中制作的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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