Last Updated: February 25, 2016
·
403
· earl3s

Stop someone from highjacking your work with an iFrame

You can block a specific domain from embedding your website if you don't mind your content in some locations but don't want it on a certain site. For example, if offendingdomain.com was embedding your content, you could do this:

<script type="text/javascript">
    if(document.referrer.indexOf("offendingdomain.com") != -1) {
        window.location = "http://www.youtube.com/watch_popup?v=oHg5SJYRHA0";
    }
</script>

This would check the parent document's location and see if it's the offendingdomain.com that is embedding your content. This script will then send that iframe to a certain famous youtube video as punishment. In effect they just Rick-Rolled themselves.