2012-07-13 22 views
0

我已經在nav上成功實現了scrollTo腳本avalonbyeaw.com,我的客戶希望添加主頁上的鏈接。很簡單,對吧?我猜不會。它不僅不會滾動,還會將#finishes添加到我們從導航鏈接中刪除的網址中。我猜我只需要添加鏈接到某個地方的功能?我無法弄清楚。scrollTo插件不滾動鏈接以外的鏈接

的Javascript

$(document).ready(function() { 

    $('a.panel').click(function() { 

     $('a.panel').removeClass('selected'); 
     $(this).addClass('selected'); 

     current = $(this); 

     $('#wrapper').scrollTo($(this).attr('href'), 800);  

     return false; 
    }); 

    $(window).resize(function() { 
     resizePanel(); 
    }); 
}); 

function resizePanel() { 

    width = $(window).width(); 
    height = $(window).height(); 

    mask_width = width * $('.item').length; 

    $('#debug').html(width + ' ' + height + ' ' + mask_width); 

    //$('#wrapper, .page').css({width: width, height: height}); 
    //$('#stage').css({width: mask_width, height: height}); 
    $('#wrapper').scrollTo($('a.selected').attr('href'), 0); 
} 

工作導航鏈接的HTML

<div id="nav-finishes" class="nav"><a href="#finishes" class="panel panel-finishes" alt="finishes"><img src="images/spacer.gif" height="10" width="79" border="0" /></a></div> 

非工作的鏈接添加到piecemaker XML提要

<Text>&lt;p&gt;Avalon by EAW features automotive-class finishes on all trim pieces. &lt;a href="#finishes" class="panel"&gt;Optional premium enclosure finishes&lt;/a&gt; set these systems in a class by themselves.&lt;/p&gt;</Text> 
+0

啊,如果我拼寫正確,將會有所幫助。它鏈接,但它不動畫。仍然無法確定這一部分。任何人? – 2012-07-13 21:19:28

+0

你知道如何從flash內部訪問js環境嗎? – Fresheyeball 2012-07-13 21:27:42

+0

所發生的一切就是你的鏈接有標準的行爲。 – Fresheyeball 2012-07-13 21:29:28

回答

0

的jQuery不必附加點擊事件的能力處理程序到Flash中返回的XML,這就是您的腳本失敗的原因。

可能膩黑客:

,請返回像這樣的XML。

&lt;a href="#finishes" onClick="$('#nav-finishes a').trigger('click'); return false;" class="panel"&gt; 

的這裏的想法是,當用戶點擊了XML的鏈接,就會觸發對主要資產淨值,這是我們知道的是已經工作的虛擬點。

可能更好黑客:

安裝這個jQuery撐着:http://benalman.com/projects/jquery-hashchange-plugin/

然後,你可以做這樣的事情:

$(window).hashchange(function(e){ 
    e.preventDefault(); 
     $('#wrapper').scrollTo(location.hash, 800); 
}); 

,你可以直接刪除$('#wrapper').scrollTo($(this).attr('href'), 800);

+0

沒有骰子,仍然像往常一樣鏈接,並追加散列到URL – 2012-07-13 21:46:25

+0

嘗試在大寫字母C onClick(我的壞) – Fresheyeball 2012-07-13 21:49:54

+0

仍然沒有。動畫,就是。還沒有嘗試過散列問題 – 2012-07-13 22:56:29