感谢您的支持,我会继续努力的!
打开微信扫一扫,即可进行扫码打赏哦
点我查看本站打赏源码!
Powered by RUNCODEX.COM,学的不仅是技术,更是梦想!!!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runcodex.com)</title>
</head>
<body>
<p>该实例演示了如何使用 HTML DOM 向 body 元素中添加 "onhashchange" 事件。</p>
<p>点击按钮修改当前 URL 的锚部分为 #part5</p>
<button onclick="changePart()">点我</button>
<p id="demo"></p>
<script>
// 使用 location.hash 属性来修改锚部分
function changePart() {
location.hash = "part5";
var x = "锚部分现在为: " + location.hash;
document.getElementById("demo").innerHTML = x;
}
document.getElementsByTagName("BODY")[0].onhashchange = function() {myFunction()};
function myFunction() {
alert("锚部分已修改!");
</script>
</body>
</html>
输入 JavaScript 代码……
xxxxxxxxxx
输入 CSS 代码……