DOMにHTMLを入力する呼び出しを#pageContent
介してロードする単純なajax Webサイトを構築しています。php
内のリンクには Fancybox を使用しています#pageContent
。問題は、ファンシーボックスがもう機能せず、リンクがまったく機能しないにもかかわらず、別のページに移動するとファンシーボックスが正常に機能するホームページにあります。setTimeout
私は試してみた 、pageLoad()
、および他の多くのアイデアの周りにスクリプトを移動しました。誰か私がこれに夢中になっているのを助けてください:
コードは次のとおりです。
Ajax 呼び出し:
var default_content="";
$(document).ready(function(){
checkURL();
$('ul li a').click(function (e){
checkURL(this.hash);
});
//filling in the default content
default_content = $('#pageContent').html();
setInterval("checkURL()",250);
});
var lasturl="";
function checkURL(hash)
{
if(!hash) hash=window.location.hash;
if(hash != lasturl)
{
lasturl=hash;
// FIX - if we've used the history buttons to return to the homepage,
// fill the pageContent with the default_content
if(hash=="")
$('#pageContent').html(default_content);
else
loadPage(hash);
}
}
function loadPage(url)
{
url=url.replace('#page','');
$('#loading').css('visibility','visible');
$.ajax({
type: "POST",
url: "load_page.php",
data: 'page='+url,
dataType: "html",
success: function(msg){
if(parseInt(msg)!=0)
{
$('#pageContent').html(msg);
$('#loading').css('visibility','hidden');
}
}
});
}
Fancybox スクリプトの起動:
$(document).ready(function(){
$(".extLink").fancybox({
'width' : '75%',
'height' : '100%',
'autoScale' : false,
'transitionIn' : 'elastic',
'transitionOut' : 'fade',
'type' : 'iframe'
});
});
問題へのリンクは次のとおりです。