获取href连接并跳转

获取href连接:

<!DOCTYPE html>  
<html>  
<head>  
<script src="/jquery/jquery-1.11.1.min.js"></script>  
<script>  
$(document).ready(function(){  
  $("button").click(function(){  
    alert($("#w3s").attr("href"));  
  });  
});  
</script>  
</head>  
  
<body>  
<p><a href="http://www.w3school.com.cn" id="w3s">W3School.com.cn</a></p>  
<button>显示 href 值</button>  
</body>  
  
</html>  

 

跳转:

1.在原来的窗体中直接跳转用  
  
window.location.href="你所要跳转的页面";  
  
2、在新窗体中打开页面用:  
  
window.open('你所要跳转的页面');  
  
window.history.back(-1);返回上一页  

  

 

posted @ 2017-04-20 14:54  front-gl  阅读(957)  评论(0编辑  收藏  举报