Posted - 08/19/2018 : 22:00:33
This problem is as old as the internet. Unscrupulous websites "frame" your website then surrond the page with ads or other junk which may have a negative impact on your site, and not just in sales, but reputation as well. It use to be a simple JavaScript to the effect <script type="text/javascript"> (function(window) { if (window.location !== window.top.location) { window.top.location = window.location; } })(this); </script> solved the problem. But with more browsers blocking automatic redirects such as this (Chrome being one) using this script is problematic. Here is an alternative. If you cannot get out of the frame, no sense letting them use your site at all. Simply place this in the <head> of your page(s) <style> html{display:none;} </style> <script> if(self == top) { document.documentElement.style.display = 'block'; } else { top.location = self.location; } </script> What this simply does is stop the display of your page's content. Yes, you might be stuck in a frame, but your content cannot be taken advantage of. I have tested this and it works like a charm. But remember, nothing is 100%. MarshallCENLYT Productions - ms designs Affordable Web Design Custom Ecommerce Designs Responsive Websites Cenlyt.com
|