使用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’);