js-7-15
//页面跳转
<h1>第一页</h1>
<a href="page2.html">跳转第二页</a>
<input id="btn" type="button" value="前进"/>
<script type="text/javascript">
var btn = document.getElementById("btn");
btn.onclick = function() {
window.history.go(-1);
}
</script>
//相对移动,针对IE
// window.moveBy(100,100);
// window.moveTo(100, 100);
// window.resizeBy(300, 300);
// window.resizeTo(300, 300);
//浏览器离左边屏幕和上边屏幕的距离
// alert(window.screenLeft);
// alert(window.screenTop);
// alert(document.body.offsetWidth);
// alert(document.body.offsetHeight);
// alert(window.screenX);
// alert(window.screenY);
//计时
var btn = document.getElementById("btn");
var btn2 = document.getElementById("btn2");
var txt = document.getElementById("txt1");
var r;
btn.onclick = function() {
function test() {
var day = new Date();
txt.value = day;
r = window.setTimeout(test, 1000);
}
test();
};
btn2.onclick = function () {
window.clearTimeout(r);
};
//锚点操作
<a name="a" href="#">锚点1</a>
<a name="a" href="#">锚点2</a>
<a href="#">锚点3</a>
<div></div>
<script type="text/javascript">
alert(document.anchors[0].innerHTML);
</script>
<a href="#a">回到顶部</a>