2011-09-24 61 views
2

http://www.alphenweer.nl/index.php#page:alphen-afgelopenuur.phpjQuery Fancybox&使用location.hash加載文件都不起作用

你會看到的第一件事是第一個bug。

我使用位於我的index.js文件中的函數getdata()來調用頁面,並將它放在主DIV中。這可能是一個問題,如果有人想鏈接到某個頁面,人們仍然需要點擊另一個鏈接。所以我用這個解決方案想出了(這也設在我index.js文件:

function getdataonload(){ 
    var page = window.location.hash; 
    if(window.location.hash != ""){ 
     page = page.replace('#page:', ''); 
     getdata('nosub/content/'.page); 
    } 
} 

// and for the links: 
<a href="#page:alphen-afgelopenuur.php">..</a> 

但是,這似乎並沒有正常工作的DIV現在被再次充滿了我的主index.php文件爲什麼。發生這種事情,我做錯了什麼?

而且我似乎也有另一個錯誤與jQuery Fancybox 例如,去同一個鏈接,點擊「Ontladingen」,然後選擇其中一個鏈接彈出。這些網頁的來源是almoast相同的,但它是這樣的:

<a href="link/to/image.png" class="fancybox"> 
    <img src="link/to/image.png" alt="example"> 
</a> 

,然後在我的頁面的底部,我有這段代碼:

<script type="text/javascript"> 
    $("a.fancybox").fancybox(); 
</script> 

現在,它應該工作。但它不起作用。爲什麼呢,我該如何解決這個問題? 你能幫我解決我的兩個問題嗎?

回答

0

對於第一problem-

你必須在getdata('nosub/content/'.page);構建完整的URL。它應該像'http:// ... nosub/content/'

對於第二個問題 -

你可以嘗試如下編寫代碼 -

<script type="text/javascript"> 
    $(document).ready(function() { 
    $("a.fancybox").fancybox(); 
    }); 
</script>