日期:2014-05-16  浏览次数:20354 次

js判断页面是否在iframe或者frame里的一种偏锋写法
整体思路:
   判断页面最顶层的location地址,最后一个'/',看是否跟iframe的源地址匹配,如果不匹配,则必然页面被嵌进了window.top 的location中,

var l = window.top.location.toString(),la = l.split('/') ,act = la[la.length -1];

if(act != 'frame.action'){
    //页面被嵌进iframe后 的操作,此处跳转器父级页面
    window.parent.location.href =='http://www.baidu.com'
}