Behold a simple framebuster:
<script type="text/javascript">
if (top.location != self.location) {
top.location = self.location.href;
}
</script>
However, it seems to work too well. It breaks the customizer admin page in WordPress whereupon the site is previewed in a frame as you customize certain settings. How can I modify this so that it breaks frames...but not that one.
Perhaps you could:
- Check if it's on the same domain and not break those frames?
- Check for the specific customizer URL using a regular expression match of somesort?
I'm happy with either solution, but I don't know how to make them happen. Any help would be appreciated.
So apparently the top.location has a field called pathname that contains the URL without the domain. By checking that field, I can exclude that specific admin page.
Update: I added the solution that checks for cross domain and catches any errors.