[JavaScript学习记录] BOM小记

浏览器对象模型(Browser Object Model)

浏览器对象包括
Window(窗口)
Navigator(浏览器)
Screen (客户端屏幕)
History(访问历史)
Location(浏览器地址)

目录

History

Nevigator

弹框

警告框alert​

 确认框conform

 输入框


History

history.go(-2); //-1表示上次,-2表示上上次,以次类推

History使用有前提,无论你使用的是a标签还是button, target不可以是_blank,其余属性(_self、_parent、_top、framename)都可以。

Nevigator

(浏览器对象,提供浏览器相关的信息)

 .appName 浏览器产品名称
.appVersion浏览器版本号
.appCodeName浏览器内部代码
.platform操作系统
.cookieEnabled是否启用Cookies
.userAgent 浏览器的用户代理报头

弹框


警告框alert

 确认框conform

​​​​​​​  var d = confirm("是否要删除");
  if(type(d)==true){
        alert("哈哈哈哈");
  }else{
          alert("呜呜呜呜");
  }

"确定"

"取消"

 

 输入框

<script>
function p(){
var name = prompt("请输入用户名:");
alert("您输入的用户名是:" + name);
}
</script>

<button onclick="p()">请输入用户名</button>

 ​​​​​​​

posted @ 2021-08-11 23:10  泥烟  阅读(18)  评论(0编辑  收藏  举报