0

Is it any way to check current domain if it's set to example.com then page won't be redirected and if URL is not set to current domain then page will be redirected to example.com?

Actually I want to check if other domains are using FRAMESET to my website then those websites will be redirected to my website.

I found this following JavaScript code:

if ( window.self !== window.top ) {
window.top.location.href=window.location.href;
}

but there is a problem here, some of my pages will be redirected to Page not found! maybe because I'm using google iframe.

*

  • However this question is look like duplicated, but the main issue in this question is about when we are using iframe in our website and if we will use above JavaScript line then our website will be redirected too, but I'm going to avoid other domains to use FRAMESET to my website.
  • -

Is it possible to avoid FRAMESET for other domains while we are using google iframe too (for example)?

I highly appreciate your help

user6276867
  • 99
  • 1
  • 3
  • 10
  • confused but i think your asking how to use iframes, but stop people iframing your site? –  Jun 19 '16 at 05:22
  • Stop people iframing to my website. how to do it ? – user6276867 Jun 19 '16 at 05:25
  • Could you check the window.top in your code to see if it is your i frames window as well? if( !(window.top === window)) //if true here, there is a parent window above you. I think that's the syntax but doing it on the fly – Coty Embry Jun 19 '16 at 07:22
  • Yes right, finally I found a solution, because I'm using google iframe that's why I got this problem, I changed iframe to embed then the problem solved. – user6276867 Jun 20 '16 at 07:24

0 Answers0