AngularJs锚点监听
来源:互联网 发布:嘉兴学院客户端mac 编辑:程序博客网 时间:2024/06/05 19:57
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>AngularJS 路由和多视图</title> <style> body { padding: 0; margin: 0; background-color: #F7F7F7; font-family: Arial; } .wrapper { width: 980px; margin: 50px auto; } ul { padding: 0; margin: 0; overflow: hidden; list-style: none; background-color: #000; border-radius: 4px; } li { float: left; width: 120px; height: 40px; text-align: center; line-height: 40px; font-size: 18px; } li.active { background-color: #333; } li a { display: block; color: #FFF; text-decoration: none; } .content { margin-top: 30px; font-size: 24px; padding: 0 20px; } </style> </head> <body> <div class="wrapper"> <!-- 导航菜单 --> <ul> <li class="active"> <a href="#index">Index</a> </li> <li> <a href="#introduce">Introduce</a> </li> <li> <a href="#contact">Contact Us</a> </li> </ul> <!-- 内容 --> <div class="content"> Index Page </div> </div> <script> // 监听锚点变化然后发送请求 // hashchange事件可以监听锚点变化 window.addEventListener('hashchange', function () { var hash = location.hash;// 获取锚点 #index.. hash = hash.slice(1); // 锚点截取 index.. var xhr = new XMLHttpRequest; // 将锚点做为参数传递给服务端进处理 xhr.open('get', '10-01.php?hash=' + hash); xhr.send(null); xhr.onreadystatechange = function () { if(xhr.readyState == 4 && xhr.status == 200) { var result = xhr.responseText; // 将返回结果添加到页面 document.querySelector('.content').innerHTML = result; } } }); </script> </body> </html>
0 0
- AngularJs锚点监听
- AngularJS 锚点
- 原声js 锚点监听
- angularJS添加事件监听
- AngularJS 监听变量变化
- AngularJS 04(监听、指令)
- angularJS URL中的锚点(#)
- angularJS-实现锚点跳转实例
- JQ实现滚动监听锚点跳转
- angularjs $watch监听模型变化
- $watch--angularJs的监听事件
- Angularjs中的注意点
- AngularJS 基础点
- AngularJs中锚点的使用,及锚点偏移量设置
- angularJs中跳转到指定的锚点详解($anchorScroll)
- 解决angularjs锚点跟路由冲突的问题
- AngularJS学习:AngularJS的甜蜜点
- 监听那点事
- linux2.6内核SD Card Driver详细解析之一
- 关于西门子PLC中数据类型的使用
- A Discriminative Feature Learning Approach for Deep Face Recognition 的源码部分分析
- bzoj 3683: Falsita 树链剖分+线段树
- Android 自定义View(一)
- AngularJs锚点监听
- 导入数据出错With the Partitioning, OLAP and Data Mining options
- FPGA 学习笔记(十一) VGA驱动的实现
- 简单说一说数据结构——队列
- CCF之图像旋转(java)
- Python中easygui的使用
- Linux内核-spin_lock()
- 对windows更多的理解
- web服务器集群