使用iframe框架引用网页,是某些不法分子的“钓鱼”手段。如果你发现自己的WordPress站点网页被另外非授权网站框架引用,改如何应对?很简单,将下面的代码添加到你的WordPress主题的 functions.php 即可:
1 2 3 4 5 6 7 8 9 10 11 | // Break Out of Frames for WordPress function break_out_of_frames() { if (!is_preview()) { echo "\n<script type=\&;text/javascript\&;>"; echo "\n<!--"; echo "\nif (parent.frames.length > 0) { parent.location.href = location.href; }"; echo "\n-->"; echo "\n</script>\n\n"; } } add_action('wp_head', 'break_out_of_frames'); |
// Break Out of Frames for WordPress function break_out_of_frames() { if (!is_preview()) { echo "\n<script type=\&;text/javascript\&;>"; echo "\n<!--"; echo "\nif (parent.frames.length > 0) { parent.location.href = location.href; }"; echo "\n-->"; echo "\n</script>\n\n"; } } add_action('wp_head', 'break_out_of_frames');
以上就是防止WordPress站点被别人通过iframe框架引用。你只有一定要,才一定会得到。更多关于防止WordPress站点被别人通过iframe框架引用请关注haodaima.com其它相关文章!