7
Cannot open link in iframe
if (self != top) { top.location.replace(window.location.href) }
I need something in javascript that is contrary to this. I want my URL to work only within an iframe
7
Cannot open link in iframe
if (self != top) { top.location.replace(window.location.href) }
I need something in javascript that is contrary to this. I want my URL to work only within an iframe
1
Unfortunately there will always be ways to circumvent this type of lock mainly with the use of javascript however for laymen the simple validation would be enough.
function IsFrame () {
try {
return window.self !== window.top;
} catch (e) {
return true;
}
}
1
Use the code below to check that the window in which the page was loaded is the browser window itself and 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!');
}
Browser other questions tagged javascript get
You are not signed in. Login or sign up in order to post.
Related (opposite) :http://answall.com/questions/108087/howto prevent que-me-site-seja-renderizado-em-um-iframe
– Guilherme Lautert
There’s a way, but there’s always room :\
– Wallace Maxters
Something like that:
if (self == top) { top.location.replace('http://pagina.que/mostra/o_frame') }
– Bacco