You can use JavaScript, I think something like the following should work:
if (top != self) {
Link to the original, meyerweb, article .
Edited regarding updating the question:
Addition : I am particularly interested if there was a method for checking this on the server, and not on the client with Javascript
This cannot be "checked" on the server side, but you can use the X-Frame-Options
header, there are two options
DENY
: prevents the creation of a frame anywhere (provided that the browser supports the X-Frame-Options header) orSAMEORIGIN
: this allows you to create a resource using only pages from the same domain, similar to a JavaScript policy with the same source code.
To use this, you need to configure the server to send the appropriate header; although specific recommendations for this cannot be given without knowing which server you are working on; although a related article in the Mozilla Developer Center shows the Apache option.
source share