2009-11-09 110 views
0

我點擊了iframe中的鏈接,並使用jquery將父文件中的html文件加載到div中。這會將內容加載到父窗口的div中(我使用top.document來引用它),但該HTML文件的一部分正在使用新變量加載swfobject,以播放不同的swf。它可以在一個頁面上正常工作,但是如果我從iframe調用它,它不會重新加載SWFObject,但會加載HTML文件的其餘部分...我很困惑。iframe swfObject加載問題

+0

這將有助於查看相關的html和javascript代碼。 – jessegavin 2009-11-10 00:24:42

回答

0

肯定的: HTML代碼中的父窗口:

<div id="filmblock"> 
content gets loaded inside this div 
</div> 

<div style="float:right"> 

<iframe src="onlinefilms.html" style="border:1px #deebf7 none; margin-bottom:28px;" name="onlineFilms" scrolling="yes" frameborder="1" marginheight="10px" marginwidth="10px" height="420px" width="360px"></iframe> 

iframe code: 

    <script src="../../global/jquery.js" type="text/javascript"></script> 

<script type="text/javascript"> 
function loadContent(elementSelector, sourceURL) { 
$(""+elementSelector+"", top.document).load("load_desc/"+sourceURL+""); 
} 

鏈接:

<a href="javascript:loadContent('#filmblock', 'adjustyourcolor.html');"><img src="../images/thumbs/72x72/adjustyourcolor_trailer_th.jpg" alt="" width="50" height="50" border="0"></a> 

代碼的HTML文件,該文件被加載:

<div id="flashcontent" align="center"> 
    You must have flash 9 or above to view video. 
</div> 

var fo = new Custom_SWFObject("basic_player_frame_autoplay.swf", "filmstrip", "338", "301", "8", "#ffffff"); 
fo.addVariable("chosen", "adjustyourcolor_trailer"); 

fo.write("flashcontent"); 


(自定義SWFObject的和FO。變量來自自定義版本,我需要在我所使用的服務器上使用它,它與swfObject的工作原理相同,並且我一直都在使用它。

如果我從div加載函數中刪除top.document,並將div與iframe內容保持在同一頁面上,則會按預期方式加載Flash影片。當我從iframe調用它來將div加載到父窗口時,它會加載其餘內容,但不會加載Flash影片。

謝謝! Wendy