What is the general purpose of top! = self?

<script language="javascript">
    if(top !== self){
        top.location.href = location.href;
    }
</script>

in some pages, I often see this, js writing. For example, the member login interface. I don"t quite understand. Why do you write it like this? what"s the use?

if the top-level (top) is not its own (self), then redirect to the url? in the address bar I don"t think it"s right when I explain it this way. Who can explain it in a more popular way?

Don"t report me. I"m a rookie. Can"t I ask a rookie question?

Apr.05,2021

there is something called iframe


to prevent people from embedding your site into their pages and doing little tricks.


this is mainly used to prevent references by iframe.
reference: what's the difference between top.location.href and localtion.href
https://www.cnblogs.com/hlws/.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35d98-2bfdf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35d98-2bfdf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?