分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 技术分享

JS BOM

发布时间:2023-09-06 02:19责任编辑:赖小花关键词:暂无标签

BOM

1、窗口操作 open

// 新tag打开目标地址open("http://www.yahoo.com");// 自身tag转跳目标地址open("http://www.yahoo.com", ‘_self‘);// 自定义窗口打开目标地址open("http://www.yahoo.com", ‘_blank‘, ‘width=300, height=300‘);

2、历史记录 history

// 历史后退history.back();// 历史前进history.forward()

3、导航器 navigator

// 拥有浏览器信息的字符串navigator.userAgent;

4、地址信息 location

// 协议location.protocol// 服务器location.hostname// 端口号location.port// 参数拼接location.search

JS BOM操作

<!DOCTYPE html><html lang="zh"><head> ???<meta charset="UTF-8"> ???<title>BOM</title></head><body> ???<button class="b1">open</button> ???<button class="b2">前进</button> ???<button class="b3">浏览器信息</button></body><!-- open --><script type="text/javascript"> ???var b1 = document.querySelector(‘.b1‘); ???b1.onclick = function () { ???????// 新tag打开目标地址 ???????// window.open("http://www.yahoo.com"); ???????// 自身tag转跳目标地址 ???????// open("http://www.yahoo.com", ‘_self‘); ???????// 自定义窗口打开目标地址 ???????open("http://www.yahoo.com", ‘_blank‘, ‘width=300, height=300‘); ???}</script><script type="text/javascript"> ???var b2 = document.querySelector(‘.b2‘); ???b2.onclick = function () { ???????// 历史后退 ???????// history.back(); ???????// 历史前进 ???????history.forward(); ???????// history.go(num) ???}</script><script type="text/javascript"> ???var b3 = document.querySelector(‘.b3‘); ???b3.onclick = function () { ???????console.log(navigator.userAgent); ???????if (navigator.userAgent.match("Chrome")) { ???????????alert("谷歌浏览器") ???????} ???}</script><script type="text/javascript"> ???// 协议 ???console.log(location.protocol); ???// 服务器 ???console.log(location.hostname); ???// 端口号 ???console.log(location.port); ???// 参数拼接 ???console.log(location.search);</script></html>

JS BOM

原文地址:https://www.cnblogs.com/layerluo/p/9833165.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved