Changes

Frames, JavaScript and HTML

1,106 bytes added, 15:42, 19 April 2019
/* Clearing Frames */
The following lines were added (+) and removed (-):
  } }   } } Updated "frame-busting" JavaScript  if (parent.frames.length > 0) {   top.location.replace(document.location); } === Busting Frame Busting JavaScript ===You can defeat basic frame busting JavaScript if the server your page with frames is hosted on supports HTTP status 204 with a custom 204 page.    <script type="text/javascript">    var prevent_bust = 0      window.onbeforeunload = function() { prevent_bust++ }      setInterval(function() {        if (prevent_bust > 0) {          prevent_bust -= 2          window.top.location = 'http://server-which-responds-with-204.com'        }      }, 1)  </script> The code creates a counter "prevent_bust" and increments it every time the browser attempts to navigate away from the current page by making use of the window.onbeforeonload event handler.  Parent to that is the timer setInterval() which is constantly going.  In the loop if prevent_bust ever gets incremented as a result of frame busting JavaScript then the frame is redirected to a custom 204 page.  By protocol standard 204 tells the web browser not to redirect anywhere.
Bureaucrat, administrator
16,192
edits