I use this code
<script>
<!-- Hide Script
if (top.location != self.location) {
top.location = self.location
}
//End Hide Script -->
</script>
However recently I get such errors in the chrome console and the code stopped working
(index):15 Unsafe JavaScript attempt to initiate navigation for frame with origin 'http://preview.themeforest.net' from frame with URL 'http://site.test'. The frame attempting navigation is targeting its top-level window, but is neither same-origin with its target nor has it received a user gesture. See https://www.chromestatus.com/features/5851021045661696.
(index):21 Uncaught DOMException: Failed to execute 'replace' on 'Location': The current window does not have permission to navigate the target frame to 'http://site.test''.
In Firefox and Opera this code works. In Chrome it does not work.
How to fix these errors?
It's a bit like this question