分享web开发知识

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

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

JS之BOM的几个对象

发布时间:2023-09-06 02:31责任编辑:郭大石关键词:暂无标签

location对象

浏览器的地址栏对象

//对象中的属性和方法//location对象//console.log(window.location);//地址栏上#及后面的内容//console.log(window.location.hash);//主机名及端口号//console.log(window.location.host);//主机名//console.log(window.location.hostname);//文件的路径---相对路径//onsole.log(window.location.pathname);////端口号//console.log(window.location.port);//协议//console.log(window.location.protocol);//搜索的内容//onsole.log(window.location.search);

location其他的属性和方法

<!DOCTYPE html><html lang="en"><head> ???<meta charset="UTF-8"> ???<title>Title</title></head><body><input type="button" id="btn" value="按钮"/><script> ???document.getElementById("btn").onclick = function () { ???????location.href="http://www.baidu.com";//跳转到页面的属性,浏览器有后退 ???????//location.assign("http://www.baidu.com");//跳转到页面的方法,浏览器有后退 ???????// location.reload();//重新加载--刷新 ???????//location.replace("http://www.jd.com");//替换,浏览器不能后退 ???};</script></body></html>
//通过platform属性可以判断浏览器所在的系统平台类型.//console.log(window.navigator.platform);

定时器

<script>//setInterval函数返回timeId ?var timeId = setInterval(function () { ???alert("hello");//每隔一秒弹框 ?}, 1000); ?document.getElementById("btn").onclick = function () { ???//点击按钮,停止定时器 ???//参数:要清理的定时的id的值 ???window.clearInterval(timeId); ?};</script>

JS之BOM的几个对象

原文地址:https://www.cnblogs.com/hzdwwzz/p/10332134.html

知识推荐

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