JQuery 点击链接,实现局部刷新,iframe 博客分类: JQuery jquery
JQuery 点击链接,实现局部刷新,iframe
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<script type="text/javascript" src="jquery-1.9.1.min.js">
</script>
<script type="text/javascript">
$(function(){
/* 点击事件会在超链接跳转前发生 */
$("#div_test a").click(function(){
var link = $(this).attr('href');
$('#div_view').attr('src', link);
var href = window.location.href;
window.location.href = href.substr(0, href.indexOf('#')) + '#' + link;
return false;
});
});
</script>
</head>
<body>
<div id="div_test">
<ol>
<li><a href="query.jsp">query.jsp</a></li>
<li><a href="http://www.baidu.com">baidu.com</a></li>
<li><a href="http://www.iteye.com">iteye.com</a></li>
</ol>
</div>
<iframe id="div_view" width="100%"></iframe>
</body>
</html>