Stop other websites iframing?
We run an online service (aka a script) and we have discovered a few web开发者_运维问答sites over the past few weeks putting our script on their site via iframe.
What precautions can we take to stop other people putting our site into theirs via iframe?
Thank you.
A more global solution would be something like this:
<script type="text/javascript">
if (top.location != location) {
top.location.href = document.location.href ;
}
</script>
Place it on the top of your page (inside the "head" tag).
On modern browsers, send the header X-Frame-Options
with the value DENY
. If it's a recent enough browser, it'll obey the header and tell the iframe to pack sand.
精彩评论