JS中target的不同用法:
<script>
window.location.href和location.href //是本页面跳转
parent.location.href //是上一层页面跳转
top.location.href //是最外层的页面跳转
</script>
<?php
echo "<script>top.location.href='index.php';</script>";//JS跳转
exit;
?>
检测是否为直接输入网址被打开的,如果是则跳转到指定页面。(适用于判断框架中的网页被用户直接打开后进行跳转)
<script language="javascript"> if(top==self)top.location="index.php" ; </script>
以上就是JS中top.location.href、parent.location.href不同跳转的用法的详细内容,更多关于JS中top.location.href、parent.location.href不同跳转的用法的资料请关注九品源码其它相关文章!