Can not open link in iframe
if (self != top) { top.location.replace(window.location.href) }
I need something in javascript that runs counter to this. I want my URL to work only inside an iframe
Can not open link in iframe
if (self != top) { top.location.replace(window.location.href) }
I need something in javascript that runs counter to this. I want my URL to work only inside an iframe
Unfortunately there will always be ways to circumvent this type of block mainly with the use of javascript, but for the laymen, simple validation would suffice.
function IsFrame () {
try {
return window.self !== window.top;
} catch (e) {
return true;
}
}
Use the code below to verify that the window in which the page was loaded is the browser window itself, not an iframe:
if(window==window.top) {
// Página não está em iframe, portanto lança um erro.
throw new Error('Esta página somente pode ser carregada em um iframe!');
}