1.history
<a href="javascript:history.forward()">前进</a>//forward()
<a href="javascript:history.back()">后退</a>//back()
2.location
location.reload()//刷新
location.href = "www.xxx.com"//跳转
3.节点
节点中每一个元素和属性都算一个节点
例如:<p>哈哈</p>其中有两个节点,分别是“p”标签和“哈哈”;因此才操作的过程中要注意操作的节点数.
<div style="border: 1px solid darkcyan;">
<p>节点</p>
<input type="button" value="改变节点样式" onclick="changeNodes()" />
<input type="button" value="增加节点" onclick="addNoders()" />
<input type="button" value="删除节点" onclick="removeNodes()" />
<div id="parents">
<p>呵呵</p>
<p>哈哈</p>
</div>
</div>
//改变节点
function changeNodes() {
var parents = document.getElementById("parents");
var nodes = parents.childNodes;
//alert(sonNodes.length);节点长度为5个
nodes[3].style.border = "1px solid red";
}
//增加节点
function addNoders() {
var parents = document.getElementById("parents");
var nodes = document.createElement("img");
nodes.src = "img/555.jpg";
nodes.style.border = "1px solid red";
parents.appendChild(nodes);
}
//删除节点
function removeNodes() {
var parents = document.getElementById("parents");
parents.removeChild(parents.lastChild);
}