2011-10-09 73 views
0

我試過下面的方式來顯示一個Ajax加載器圖像,直到頁面加載到HTML object。但它不適合我。下面的代碼有什麼問題?代碼在運行時不會顯示Ajax加載器圖像。Ajax頁面加載器不能在HTML對象中工作

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
    <head> 
    <title>mouseover image position</title> 
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> 

    <style type="text/css"> 
    /*<![CDATA[*/ 
    body 
    { 
    background-color:#aaaaff; 
    } 
    #one 
    { 
    position:absolute; 
    left:50%; 
    top:50%; 
    margin:-150px 0 0 -250px; 
    } 
    object 
    { 
    width:500px; 
    height:300px; 
    border:solid 1px #000000; 
    } 
    /*//]]>*/ 
    </style> 

    <script type="text/javascript"> 
    //<![CDATA[ 
    // written by: Coothead 
    function updateObjectIframe(which){ 
    document.getElementById('one').innerHTML = '<'+'object id="foo" name="foo" type="text/html" data="'+which.href+'"><\/object>'; 
    } 

    //]]> 
    </script> 
<script type="text/javascript"> 
$.ajaxStart(function(){ 
    $("#Layer10").show(); 
}); 
$.ajaxComplete(function(){ 
    $("#Layer10").hide(); 
}); 
</script> 

    </head> 
    <body> 
    <div id="one"> 
    <object id="foo" name="foo" type="text/html" data="http://www.w3schools.com/"> 
    <div id="Layer10"> 
    <img id="loading-image" src="im/ajax-loader.gif" alt="Loading..." /> 
    </div> 
    </object> 
    </div> 
    <div> 
    <a href="http://www.google.com" onclick="updateObjectIframe(this); return false;">this is an object test not an iframe test</a> 
    </div> 
    </body> 
    </html> 

回答

-1

我想這是因爲一個對象標籤並沒有被視爲瀏覽器的AJAX請求。我不知道是否有辦法實現你想要的。

+0

這必須寫在評論中,而不是回答。 –

+0

對不起。仍然不太熟悉StackOverflow。請記住它。 –

+0

沒關係!沒有問題。 –

相關問題