Jquery动态加载页面的一个简单例子:
<html>
<head>
<title>Enter the title of your HTML document here</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(
function(){
var url = "http://localhost/test2.html";
$.get(url, {}, function(data){
$("#test").html(data);
});
}
);
</script>
</head>
<body>
<div id="test"></div>
</body>
</html>
<head>
<title>Enter the title of your HTML document here</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(
function(){
var url = "http://localhost/test2.html";
$.get(url, {}, function(data){
$("#test").html(data);
});
}
);
</script>
</head>
<body>
<div id="test"></div>
</body>
</html>
其中,在test2.html中可以包含javascript代码,比如用Canvas来画图的javascript代码。