Click here to Skip to main content
15,889,839 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
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:
XML
<iframe src="PAGE LINK HERE"></iframe>

and it will redirect you from whole page that has iframe to another website
the code is like this below :
JavaScript
<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>

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?
Posted
Comments
Kornfeld Eliyahu Peter 4-May-14 11:59am    
Remove the code that prevent to put the page in iframe!
Member 10749093 4-May-14 12:07pm    
i mean another page that's using that code to prevent their pages to Not be in iframe on some websites

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900