<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<script>
document.write(new Date());
</script>
<body>
<img src="./1.jpg" alt="" id="img1" width="200">
<img src="./2.jpg" alt="" id="img2" width="200">
<p id="p1">所有标签都可以进行跳转操作 再也不用a标签跳转了</p>
</body>
<script>
document.write('获取完成url路径:'+window.location.href+'<br/>');
document.write('获取路径:'+window.location.pathname+'<br/>');
document.write('获取协议:'+window.location.protocol+'<br/>');
document.write('获取主机名:'+window.location.hostname+'<br/>');
var img1 = document.getElementById('img1');
var img2 = document.getElementById('img2');
img1.onclick=function(){
location = 'http://www.4399.com';
}
img2.onclick=function(){
//alert(2);
//location.reload();
}
setInterval(function(){
//location.reload();
},5000)
var p = document.getElementById('p1');
p.onclick=function(){
location="http://www.12306.cn";
}
</script>
</html>点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号