【发布时间】:2011-03-11 07:38:59
【问题描述】:
我正在使用此代码:
<!--Page Loading Mechanism-->
<script type="text/javascript">
$( document ).ready( function() {
$( 'a.dynamicLoad' ).click( function( e ) {
e.preventDefault(); // prevent the browser from following the link
e.stopPropagation(); // prevent the browser from following the link
$( '#MainWrapper' ).load( $( this ).attr( 'href' ) , function() {
/* Content is now loaded */
});
});
});
</script>
使用父页面中的导航菜单加载外部页面。好的,现在当我单击导航按钮时,它可以很好地加载页面。
现在,我想做的是从子页面上的按钮将另一个外部页面加载到同一个 div 中。我试图基本上用 w 页面覆盖孩子。我认为普通的< a href> 可以解决问题,但它只会在主窗口中打开新页面,替换父页面。我不想要那个。
我如何用新的外部页面替换第一个子页面,但在同一个 div 中已经加载了子页面,替换它。我会在第一个加载的子页面上写什么代码?
希望大家阅读本文时不要感到困惑,因为这是我能解释它的最佳方式。
【问题讨论】:
-
我很困惑,但是通过:“我试图用页面覆盖孩子”,你有没有想过使用 ajax 来获取页面的内容并将 responseHTML 设置为 div?