js跳转一般有window.location.href、parent.location.href、top.location.href。页面嵌套iframe子页面时,子页面的按钮如何跳转呢?

1、window.location.href、location.href  是本页面跳转

2、parent.location.href  是上一层页面跳转

3、top.location.href  是最外层的页面跳转

html5页面嵌套iframe子页面,在ios微信里打开长按识别不了二维码,原因是iframe子页面,重定向让父级页面执行事件就可以了

例如:


if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
    // 手机版
    top.location.href='http://m.kw360.net/'
} else {
    // pc版
    window.location.href='//www.kw360.net/'
}