jquery获取链接地址和跳转详解(推荐)

2022-10-22,,,,

一、获取地址栏参数的方法

获取地址栏参数的方法

<script type="text/javascript">
(function ($) {
  $.geturlparam = function (name) {
    var reg = new regexp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
  }
})(jquery);
$(function () {
  alert(window.location.href);
  alert($.geturlparam('page'));
})
</script>

获取href连接:

$(document).ready(function(){ 
 $("button").click(function(){ 
  alert($("#w3s").attr("href")); 
 }); 
});

二、跳转

1.在原来的窗体中直接跳转用 

window.location.href="你所要跳转的页面" rel="external nofollow" ;

2、在新窗体中打开页面用: 

window.open('你所要跳转的页面'); 
window.history.back(-1);返回上一页

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助~如果有疑问大家可以留言交流,谢谢大家对的支持!

《jquery获取链接地址和跳转详解(推荐).doc》

下载本文的Word格式文档,以方便收藏与打印。