• javascript -window与document 待整理


    window对象和document对象的区别
    一般来讲,一个window里就是一个document,但是,iframe里面也可以装个document,在iframe里面就有区别了

    alert(document.location === window.location); // true

    不要混淆Window对象的location属性和Document对象的location属性。前者引用一个Location对象,而后者只是一个只
    读字符串,并不具有Location对象的任何特性。document.location与document.URL是同义的,后者在
    JavaScript1.1中是该属性的首选名称(因为这样避免了潜在的混淆)。在大多数情况下,document.location和
    location.href是相同的。但是,当存在服务器重定向时,document.location包含的是已经装载的URL,而
    location.href包含的则是原始请求的文档的URL。

    document.location和window.location有什么区别就是
    document你可以理解为文档,就是你的网页
    window理解为窗口,就是你的ie浏览器包含的
    无框架:简单的说,没有框架的情况下,是等同的
    有框架:在有框架的情况下,最外层是相同的,在iframe里面的document.location和window.location不同的。
    iframe里面的document.location 你看不ie地址变化,只改变iframe部分,
    此时的window.location和top.location效果一致

    document.location="url";(只读)
    document.location.reload("url";);
    window.location="url";
    location="url";
    document.href="url"
    document.location.href="url"
    document.location.replace="url"
    document.action="url"; document.submit();
    document.location.href和document.location.replace都可以实现从A页面切换到B页面,但他们的区别是:
    用document.location.href切换后,可以退回到原页面。而用document.location.replace切换后,不可以通过“后退”退回到原页面。
    关于document.location.href或其他可回退的切换方式
    document.location 相当于 document.URL 声明了装载文档的URL,
    除非发生了服务器重定向, 否则该属性的值与Window.location.href的值是一样的.
    history.go(-1);//返回上一页
    document.IFRAME名称.location.href='url';//改变框架内容 
           

    一步一个脚印,方便自己复习,该出手时就出手,有错误,一定要指正,非常感谢,共同进步!
  • 相关阅读:
    [原创]网页级在线性能测试网站介绍
    [原创]浅谈测试团队文化
    [原创]浅谈自动化测试中的金字塔模型理解
    [原创]如何在面试时选择合适的测试人员?
    [原创]浅谈怎么写周报
    [原创]Windows下调试工具介绍
    [原创]浅谈我对持续集成的理解
    [原创]IBM AppScan工具培训
    [原创]Jenkins持续集成工具介绍
    [原创]什么是信息安全资产管理?
  • 原文地址:https://www.cnblogs.com/keyi/p/6137483.html
Copyright © 2020-2023  润新知