记录个人遇到的并且觉的经常复用的js,jquery
代码块。
公共
使用jQuery
首先引用jQuery
文件,如下示例:
1 | <script type="text/javascript" src="/static/js/jquery-1.11.0.min.js"></script> |
设置和获取URL
window.location
对象获取当前页面URL
信息,可不使用window
前缀。
根据该对象的属信可以获取更详细的信息,也可设置信息。alert(location)
;alert(document.URL);
,输出 url 地址。alert(location.href);
,输出完整 URL 地址。location.href = '/admin/user/login?id=' + id;
,页面跳转(设置URL值)。document.referrer;
,获取来源URL。