With JavaScript you can do
if(window.top==window){
//not inside iframe
} else {
if(parent.parent.someFunction){
parent.parent.someFunction();
} else {
alert("framing is not allowed")
}
}
OR
if (window.top !== window.self) window.top.location.replace(window.self.location.href);
Some modern browsers also support the X-FRAME-OPTIONS header, that can have two values:
* DENY – prevents the page from being rendered if it is contained in a frame
* SAMEORIGIN – same as above, unless the page belongs to the same domain as the top-level frameset holder.
Browsers that support the header:
* IE8 and IE9
* Opera 10.50
* Safari 4
* Chrome 4.1.249.1042
* Firefox with NoScript
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…