浏览器相关信息

// 浏览器信息

navigator.userAgent // Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36

// 运行浏览器的操作系统平台

navigator.platform // MacIntel

浏览记录历史

// 前进

history.forward()

// 后退

history.back()

url 信息

页面跳转

// 当前页面会记入浏览记录历史

location.href = 'http://www.baidu.com'

// 当前页面不会记入浏览记录历史

location.replace('http://www.baidu.com')

页面重新加载

location.reload()

获得当前 url 的信息

// 假设当前 url 是 http://192.168.31.194:8000/jquery/index.html?a=3&c=aa#b

location.href // 完整的url

location.hostname // 192.168.31.194

location.host // 192.168.31.194:8000

location.port // 8000

location.protocol // http:

location.search // ?a=3&c=aa

location.hash // #b

location.pathname // /jquery/index.html

全局对象

信息弹出框

alert('你很帅!')

确认弹出框

var isReady = confirm('准备好来吗?')

if (isReady) {

} else {

}

输入信息弹出框

var name = prompt('请输入你的名字')

console.log(name)

打开一个新窗口

open('http://baidu.com')

// 改变某个窗口的 url

open('http://baidu.com', 'a')

open('http://youku.com', 'a') // 上面窗口的地址会从 百度 变成 优酷的

过段时间后执行

// 1 秒后执行

setTimeout(function() {

// doSth

}, 1000)

每隔一段时间执行

var i = 1

// 每隔 1 秒后执行

var runId = setInterval(function(){

console.log(i++)

if(i >= 10) {

clearInterval(runId) // 停止执行

}

}, 1000)

屏幕每次刷新时执行

一般是渲染一些 UI。

var targetEl = document.querySelector('.tar')

var res

var isStop

var runId = requestAnimationFrame(function(){

targetEl.text(res)

if(isStop) {

cancelAnimationFrame(runId)

}

})

在控制台输出信息

console.log('日志信息')

console.warn('警告信息')

console.info('普通信息')

console.error('错误信息')

console.log('1+2 = %d', 3)

var person = {name: 'Joel', gender: '男'}

console.log('名字:%s,性别:%s', person.name, person.gender)

161122、BOM 操作写法示例的更多相关文章

  1. BOM操作写法实例

    浏览器相关信息 // 浏览器信息 navigator.userAgent // Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/ ...

  2. jsp的三种自定义标签 写法示例

    1.自定义方法标签 引入方式示例: <%@ taglib prefix="fns" uri="/WEB-INF/tlds/fns.tld" %> 写 ...

  3. day45:JS中的json&JS的BOM操作和DOM操作

    目录 1.补充:CSS中的弹性盒子 2.JS中json的序列化 3.JS中的BOM操作 3.1 location操作 3.2 计时器 4.JS中的DOM操作 4.1 创建标签 4.2 查找标签 4.3 ...

  4. BOM操作

    BOM操作 //浏览器对象模型 opener=window.open(页面的url,打开方式) opener.document.body.style.background="red" ...

  5. 关于SVN的操作批处理示例

    关于SVN的操作批处理示例 为了一句话:不要动手做机器能够做的事情. 天天工作用svn,更新啥的打开目录啥的动作天天在重复.每次写些命令也蛮无聊的,不说了,看下面: 1 @echo off 2 rem ...

  6. Python操作SQLServer示例(转)

    转自:http://www.cnblogs.com/lrzy/p/4346781.html 本文主要是Python操作SQLServer示例,包括执行查询及更新操作(写入中文). 需要注意的是:读取数 ...

  7. 转:Python操作SQLServer示例

    注:此文也是转载,2018年1月发现此文阅读量过万,略感不安.当时只是为了自己存档学习,未粘此文的原始连接.如有侵权,通过即删除,敬请谅解! 从网上找的,估计原文是:Python操作SQLServer ...

  8. C#操作MSMQ示例

    C#操作MSMQ示例,示例代码: using System; using System.Collections.Generic; using System.Linq; using System.Tex ...

  9. Python操作SQLServer示例

    本文主要是Python操作SQLServer示例,包括执行查询及更新操作(写入中文). 需要注意的是:读取数据的时候需要decode('utf-8'),写数据的时候需要encode('utf-8'), ...

随机推荐

  1. 使用Aspose.Cell控件实现Excel高难度报表的生成(一)

    时光飞逝,生活.工作.业余研究总是在不停忙碌着,转眼快到月底,该月的博客文章任务未完,停顿回忆一下,总结一些经验以及好的东西出来,大家一起分享一下.本文章主要介绍报表的生成,基于Aspose.Cell ...

  2. dede如何实现二级栏目导航的仿制

    {dede:channelartlist row='2' typeid='1,2' }<h3><a href='{dede:field name='typeurl'/}'>{d ...

  3. JavaScript:下拉列表框的事件处理

    下拉列表框处理操作主要使用的是一个onchang的事件,此事件描述的是内容改变后行为. 范例:观察下拉列表框的事件处理 代码: <!doctype html> <html lang ...

  4. zabbix监控activemq队列脚本

    公司业务使用activemq5.9.1消息队列,由于队列阻塞导致程序端口无响应,并且telnet无法连通.经过over 1 hour的排查,最终定位原因activemq导致.遂写了一个监控active ...

  5. RFS一些基本概念

    1. Project.Directory.TestSuit.TestCase.Resource的区别?   Project:项目名称   Directory:对项目进行分层   TestSuit:测试 ...

  6. sqlserver中索引优化

    背景: MRO表中TimeStamp nvarchar(32),但实际上它存储的内容是日期(2015-09-09 11:20:30). 现在我要执行这样一个sql语句: Select t10.* fr ...

  7. c++ template怎么使用及注意事项

    c++ 中的template和c#的什么有点相似? 先看下定义方式: template <typename|class T> T myFunction(T param1,T param2. ...

  8. Lintcode: Binary Tree Serialization (Serialization and Deserialization Of Binary Tree)

    Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a ...

  9. AIR 中的 File 对象 所访问的文件夹位置

    AIR 中的 File 对象 所访问的文件夹位置 Link 关于File.cacheDirectory的一点说明 According to the Apple guidelines, data tha ...

  10. js eventhandler

    1.获取所有eventhandler 使用 getEventHandler(target) 2.target.addEventHandler(type,handler,userCapture?) 3. ...