当前位置: 移动技术网 > IT编程>开发语言>JavaScript > window.location.href和window.top.location.href的区别

window.location.href和window.top.location.href的区别

2019年01月23日  | 移动技术网IT编程  | 我要评论

if (window.location.href == window.top.location.href) {     window.top.location.href = "/"; }

top.window.location.reload即刷新父级页面  中top是指父框架的对象

使用情况一般是有嵌套iframe 其iframe的父页面为本<html><iframe src='2.htm'></iframe> <html>

 

2. 也就是 如果iframe中的 2.htm 里面 使用了: top.window.location.reload 那么就是 刷新父页面

    如果2.htm里面使用的是: window.location.reload 那就是 刷新框架 自身页面 即iframe中的页面

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网