博客
关于我
JS-BOM
阅读量:344 次
发布时间:2019-03-04

本文共 1194 字,大约阅读时间需要 3 分钟。

思维导图与JavaScript窗口对象操作

一、思维导图

通过思维导图可以直观地展示知识体系,帮助我们更好地理解相关内容。在这个案例中,我们主要关注的是JavaScript中的window对象及其常用方法。

二、window.open方法

window.open 是JavaScript中最常用的打开新窗口或切换窗口的方法。它支持以下几种常见用法:

  • 打开新窗口:window.open('http://www.baidu.com');
  • 在当前窗口打开新页面:window.open('http://www.baidu.com', '_self');
  • 在新窗口打开页面:window.open('http://www.baidu.com', '_blank');
  • 在父窗口打开页面(适用于 iframe嵌入的内容):window.open('http://www.baidu.com', '_parent');
  • 在顶级窗口打开页面(通常用于解决浏览器的同源政策问题):window.open('http://www.baidu.com', '_top');

三、window.close()方法

当需要关闭当前窗口或 iframe嵌入的内容框架时,可以使用 window.close() 方法。需要注意的是,某些浏览器环境下,关闭窗口可能会提示用户确认操作,确保不会误删或丢失重要数据。

四、window.confirm方法

window.confirm 用于显示一个确认对话框,用户可以选择“是”或“否”。常见的使用场景包括:

function del() {    var ok = window.confirm("亲,确认删除数据吗?");    alert(ok);}
  • window.alert():用于显示警告信息框,通常用于提醒用户某些重要操作。
  • 弹出消息框:window.alert('消息框!')
  • 弹出确认框(删除):window.confirm('确认删除数据吗?')

五、window.history方法

window.history 提供了浏览历史相关的操作。常用的方法包括:

window.history.back(); // 后退一页window.history.go(-1); // 后退一页

六、设置浏览器地址栏上的URL

可以通过以下方式控制浏览器地址栏的URL:

function gobaidu() {    window.location.href = "http://www.baidu.com";}

七、浏览器发送请求的方式

在Web开发中,浏览器可以通过以下方式向服务器发送请求:

  • 表单提交
  • 超链接
  • document.locationwindow.location
  • window.open("url");
  • 直接在浏览器地址栏输入URL并回车
  • 转载地址:http://wihe.baihongyu.com/

    你可能感兴趣的文章
    npm ERR! ERESOLVE could not resolve报错
    查看>>
    npm ERR! fatal: unable to connect to github.com:
    查看>>
    npm ERR! Unexpected end of JSON input while parsing near ‘...“:“^1.2.0“,“vue-html-‘ npm ERR! A comp
    查看>>
    npm error Missing script: “server“npm errornpm error Did you mean this?npm error npm run serve
    查看>>
    npm error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”。要解决此问题,1) 安装
    查看>>
    npm install CERT_HAS_EXPIRED解决方法
    查看>>
    npm install digital envelope routines::unsupported解决方法
    查看>>
    npm install 卡着不动的解决方法
    查看>>
    npm install 报错 EEXIST File exists 的解决方法
    查看>>
    npm install 报错 ERR_SOCKET_TIMEOUT 的解决方法
    查看>>
    npm install 报错 Failed to connect to github.com port 443 的解决方法
    查看>>
    npm install 报错 fatal: unable to connect to github.com 的解决方法
    查看>>
    npm install 报错 no such file or directory 的解决方法
    查看>>
    npm install 权限问题
    查看>>
    npm install报错,证书验证失败unable to get local issuer certificate
    查看>>
    npm install无法生成node_modules的解决方法
    查看>>
    npm install的--save和--save-dev使用说明
    查看>>
    npm node pm2相关问题
    查看>>
    npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
    查看>>
    npm run build报Cannot find module错误的解决方法
    查看>>