2011-12-26 47 views

回答

1

對於對話框使用jQuery UI

http://jqueryui.com/demos/dialog/#modal-message

要更改URL與JS使用歷史API

http://html5demos.com/history

還要檢查Good tutorial for using HTML5 History API (Pushstate?)

對於舊版瀏覽器,您可能需要使用location.hash,上面的jQuery UI站點就是一個很好的例子。

在對話框打開的所有鏈接,你可以編寫類似下面

$('a').click(function(e){ 
    e.preventDefault(); 
    var url=$(this).attr('href')+"?content_only"; //content_only added to tell index.php to give only content without template and JS 
    $.get(url, function(data) { 
    $('.dialog').html(data).dialog(); 
    //change URL here 
    }); 
}); 

對於指向所有URL主頁你必須做服務器端的技巧,指向所有URL指向index.php。像example.com/index.php/subpage和檢查文檔就緒,如果URL不只是index.php我的意思是像example.com/index.php/subpage然後在對話框中打開example.com/index.php/subpage?content_only。在index.php中使用一個標準,content_only被指定,然後只返回subpage的內容而沒有模板和JS。

+0

感謝您的快速回答。但是當你在URL地址欄中輸入www.demopage.com/example.php時,你的擁塞方法不起作用,它只會打開example.php,而在後臺沒有主頁。 – 2011-12-26 12:15:06

+0

這件事情有點棘手和細節,無論如何我已經更新了答案。 – Usman 2011-12-26 13:46:42

相關問題