我创建了一个framekiller脚本,它允许仅在选定的域中构建页面以防止点击劫持。 Framekiller代码:
<style id="antiClickjack">
body {
display: none !important;
}
</style>
<script>
if (top.length > 0)
{
if (self.location == top.location) {
alert("same");
var antiClickjack = document.getElementById("antiClickjack");
antiClickjack.parentNode.removeChild(antiClickjack);
}
else if (self.location.hostname == top.location.hostname || self.location.hostname.toString() == "www.TrustedSite1.com" || self.location.hostname.toString() == "www.TrustedSite2.com")
{
var antiClickjack = document.getElementById("antiClickjack");
antiClickjack.parentNode.removeChild(antiClickjack);
}
else
{
top.location.replace(self.location);
}
}
else
{
var antiClickjack = document.getElementById("antiClickjack");
antiClickjack.parentNode.removeChild(antiClickjack);
}
</script>
但是最新的浏览器遵循相同的原则政策所以它不允许在其他网站(受信任的网站)中执行framekiller脚本
我的问题是“如何绕过相同的原始策略在不同的域上执行framekiller脚本”
谢谢。