This is going to be short and simple tip. There are chances that your site can be put into iframe and you probably do not want that to happen. But there are not chances for your site to handle such situation, only before reading this post 😛
The window.top property of window object return you the object of the top window from the DOM hierarchy of the page. However the window.self return you an object of the iframe in which your site is opened. The if condition matches both and if they are not equal, then it changes its location to your site, this is how you wanted 😛
Now if you want to see the actual URL, i mean if u are curious to know what the window.top and window.self actually return, then you can use the following code.
Hope that helps