2012-06-03 38 views
0

我在頁面頂部有一個「position:fixed」iframe,在上面有一個水平菜單(也是固定的)。 每個菜單按鈕都將整個頁面滾動到選定的div。輸入一個DIV自動打開鏈接到iframe

有沒有辦法自動打開鏈接一旦達到該div? 我需要自動加載「iframe內容1」輸入「div#1」,「iframe內容2」​​輸入「div#2」等。

頁面有jQuery。

在此先感謝。

enter image description here

回答

0

讓我們看看,如果這個工程給你:

$('#btn1').click(function() { 
    var targetOffset = $('#div1').offset().top; 
    $('html,body').animate({scrollTop: targetOffset}, 5000, function() { 
    // Animation complete, lets load content 
    $('#div1').html($('#iframe1').contents()); 
    }); 
}); 

/** 
For the contents() to work the iframe must be getting the content from the same domain 
*/ 
+0

謝謝你,我正在上。 「#iframe1」你指的是什麼? 我有一個名爲「框架」的iframe,其中我加載了需要加載的頁面(來自同一個域)。 link Manuel

+0

我不使用target =「frame」。我假設你有#iframe1已經加載了html,所以我滾動到div,當它完成我加載iframe內容#div1 – 2012-06-03 15:20:02