How to check iframing into a iframe?

Hello i want to protect my Kongregate games but, there is a problem. Kongregate iframe the games, and seems to be Kong’s iframe is hosted on “a.kongregate.com”.

But somebody thieves the kongregate games and iframe the iframed Kongregate games.

How i can check up the parent tree to see how many levels of iframe the game is in?

And, if it is one level of iframe how check where the parent window is?

i am very noob with this, and i don´t know how to get it.

Thanks.

The frames in a browser are put in the DOM hierachy.

I havent tested if you can do this from within Unity player itself, but you can access DOM through Javascript on clients, so if you somehow call javascript from within Unity player, it should work.

The DOM will have the browser window as the “top/parent”.

Below this are your “documents/children”.

So if you are in browserwindows//iframe(thief)/iframe(kongregate)
Then you should be able to detect if TOP == KONGREGATE or not.

This sample will check if you are inside a frame or not, but at KONGREGATE you are.

if (window!=window.top) { /* I'm in a frame! */ }

This is javascript code, so you will have to figure out how to make this check from within Unity player.

Secondly, parent to your Unity game would be Kongregate, so it might be something like:

if (parent!=window.top) { /* if my parent isnt top */ }

Let me know how it works, okay? I can do Javascript too, but havent got the time right now.

function Start (){
Application.ExternalEval(“if(document.location.host != ‘a.kongregate.com’) { document.location=‘http://www.3dart.es’; }”);

Application.ExternalEval("if (parent!=window.top)  { document.location='http://www.3dart.es';}");
}

I knew the first code, but with the second i can block the Iframe thieve (the first code is when somebody upload directly the “.unity” file to their Web page).

i uploaded the game in “.unity” format and “Iframed version” to my Web page and seems to block both correctly!! (the game stops and go to my web page´s index “www.3dart.es”).

thanks a lot!!!