if (top.location !== self.location) {
top.location = self.location;
}
top:最頂層視窗(可能是攻擊者頁面)。self:當前視窗(你的頁面)。// HTTP 響應頭
Content-Security-Policy: frame-ancestors 'self' https://trusted.com;
X-Frame-Options: DENY // 完全禁止嵌入
X-Frame-Options: SAMEORIGIN // 同源允許
漸被 CSP 取代,但仍廣泛支援。