document.write(document.title);//document.title返回当前文档的标题。
document.write(document.URL);//document.URL返回文档完整的URL
document.write("Hello World!");//document.write()向文档写 HTML 表达式 或 JavaScript 代码。
document.writeln("Hello World!"); document.writeln("Have a nice day!");//document.writeln()等同于 write() 方法,不同的是在每个表达式之后写一个换行符。
window.frames[0].location = "www.runoob.com/";//frames返… Window 对象的数组,每个 Window 对象在窗口中含有一个框架。
document.write("历史列表中URL的数量: " + history.length);//length返回历史列表中的网址数
function goBack(){ window.history.back() }//back()加载 history 列表中的前一个 URL
function goForward(){ window.history.forward() }//forward()加载 history 列表中的下一个 URL
function goBack(){ window.history.go(-2) }//go()加载 history 列表中的某个具体页面
var w=window.innerWidth;//innerWidth返回窗口的文档显示区的宽度。 var h=window.innerHeight;//innerHeight返回窗口的文档显示区的高度。
// 存储 localStorage.setItem("lastname", "Smith"); // 检索 document.getElementById("result").innerHTML = localStorage.getItem("lastname");//localStorage在浏览器中存储 key/value 对。没有过期时间。
for (var i=0; i<frames.length; i++){ frames[i].location="www.runoob.com" }//length设置或返回窗口中的框架数量。
//location document.write(location.hash);//hash返回一个URL的锚部分
document.write(location.host);//host返回一个URL的主机名和端口
document.write(location.hostname);//hostname返回URL的主机名
document.write(location.href);//href返回完整的URL
document.write(location.pathname);//pathname返回的URL路径名。
document.write(location.port);//port返回一个URL服务器使用的端口号
document.write(location.protocol);//protocol返回一个URL协议
document.write(location.search);//search返回一个URL的查询部分
function newDoc(){ window.location.assign("www.runoob.com" }//assign()载入一个新的文档
location.reload();//reload()重新载入当前文档
function replaceDoc(){ window.location.replace("www.runoob.com") }//replace()用新的文档替换当前文档
var myWindow; function openWin(){ myWindow=window.open('','MsgWindow','width=200,height=100'); myWindow.document.write("
窗口名称为: " + myWindow.name + "
"); }//name设置或返回窗口的名称。//Navigator document.write("浏览器代号: " + navigator.appCodeName);//appCodeName返回浏览器的代码名
document.write("浏览器名称: " + navigator.appName);//appName返回浏览器的名称
document.write("版本信息: " + navigator.appVersion);//appVersion返回浏览器的平台和版本信息
document.write("是否启用 Cookie: " + navigator.cookieEnabled);//cookieEnabled返回指明浏览器中是否启用 cookie 的布尔值
document.write("硬件平台: " + navigator.platform);//platform返回运行浏览器的操作系统平台
document.write("用户代理: " + navigator.userAgent);//userAgent返回由客户机发送服务器的user-agent 头部的值
document.write("启用Java: " + navigator.javaEnabled())//javaEnabled()指定是否在浏览器中启用Java
document.write("启用数据污点: " + navigator.taintEnabled());//taintEnabled()规定浏览器是否启用数据污点(data tainting)
myWindow.opener.document.write("
这个是源窗口!
");//opener返回对创建此窗口的窗口的引用。var w=window.outerWidth;//outerWidth返回窗口的外部宽度,包含工具条与滚动条。 var h=window.outerHeight;//outerHeight返回窗口的外部高度,包含工具条与滚动条。