M.RK
M.RK

Reputation: 21

Protect iframe from other's and Use One domain for the iframe?

hi i want java scripts for Iframe protection and they work only one site like iframe site url is www.iframe.com and i want to protect on www.my-mainwebsite.com

i just want www.iframe.com work only on www.my-mainwebsite.com when these iframe code use another site like www.anothersite.com they will be redirect to www.my-mainwebsite.com

Upvotes: 0

Views: 1652

Answers (1)

Mr. Zijkant
Mr. Zijkant

Reputation: 19

<script type="text/javascript">
if (top !=self || top.location != "www.iframe.com") {
   top.location=self.location;
}
</script>

Here is a quick JavaScript code that you can use if you want to make sure that no one should be able to show your website in an IFrame.

Edit1:

  • Added second check in if, if site is not equal to "www.iframe.com"

Upvotes: 1

Related Questions