Reputation: 319
What I am trying to do is, if my html/css/javascript is loaded on another domain the page will clear itself, so the page will look blank when it is fully loaded. It's like a fingerprint just for my domain.
As if right now there isn't much documentation regarding this. I have found a few examples but they are not implementable.
I've seen it done before, if it didn't match with the domain name then the page would be blank.
Does anyone know how I can do this?
Upvotes: 0
Views: 981
Reputation: 1911
you can add this in your files
<style>
html {
display: none;
}
</style>
<script>
if ( top.location.host === "www.xyz.com" /* your domain */) {
document.documentElement.style.display = "block";
}
</script>
Upvotes: 1
Reputation: 18609
You can get the domain name in JS by window.location.host
, and you can clear the page using window.location.replace('about:blank')
; but this method can be bypassed/removed from code.
if(window.location.host !== 'your.domain.com') window.location.replace('about:blank')
Upvotes: 1