你能给我一些可以防止javascript注入的代码示例吗?我非常关心这个特定的广告商。也许我会在框架内打开一个外部站点或其他站点。也许必须有一些php脚本。必须有办法解决这样的问题。不可能,无论如何都是可能的。
我在互联网上找到了一个视图代码,但不知道它是如何工作的。
举个例子:
1.
<script type="text/javascript">
if(top != self) {
top.onbeforeunload = function() {};
top.location.replace(self.location.href);
}
</sript>
2.
<script type="text/javascript">
var prevent_bust = 0
var id = setInterval(function() {
if (prevent_bust > 0) {
prevent_bust -= 2
window.top.location = 'somesite_com.htm';
}
}, 1)
window.onbeforeunload = function() { prevent_bust++ }
window.onclick = function() { clearInterval(id)}
</script>
3.
<script type="text/javascript">
<!--
if (parent != self && !/^http:\/\/((www\.)|())somesite\.host>
\.com/.test(top.location.href))
top.location.replace(self.location.href);
// -->
</script>
4.
<script>
javascript:void(d=document);if(frames.length){alert('Script%20doesn/'t%20work%20in%20frames');}
else{while((el=d.getElementsByTagName('script')).length){el[0].parentNode.removeChild(el[0]);};onerror=function(){};d.close();}
</script>
所以还有什么建议。谢谢有趣。