0
最初我想將一些從iframe從遠程頁面加載的內容(div class =「StaffBlock」)轉換爲div class =「Contact-Agent-Append」。但append()方法被證明不適用於iframe。它正常工作,但由於我使用模板和模板不是靜止頁面,我認爲這是爲什麼append()不能將內容帶入當前頁面。然後我注意到clone()正在工作,但它會偶然重複20個內容的克隆。請幫助我使它克隆一次。非常感謝。來自iframe的jquery clone()內容
這是包含IFRAME原編碼:
<div class="Contact-Agent-{tag_Publish As Agent}">
<div class="Contact-Agent-Small-Logo-listing" title="this property is published by agent">
</div>
<iframe scrolling="no" height="60px" frameborder="0" width="150px" src="{tag_listing agent staff url}" marginwidth="0px" marginheight="0px" style="overflow:hidden; margin:0; padding:0; display: none;"></iframe>
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$('iframe').contents().find('.StaffBlock').clone().appendTo($('.Contact-Agent-Append'))
});//]]>
</script>
<div class="Contact-Agent-Append">content should go here
</div>
</div>
這是存儲在遠程URL包含了StaffBlock內容:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/StyleSheets/listing-contact.css" />
</head>
<body>
<div class="listing-contact">
<div class="StaffBlock">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="col-a">{tag_name}</td>
<td class="col-b" rowspan="4">{tag_Staff Photo}</td>
</tr>
<tr>
<td>{tag_job title}</td>
</tr>
<tr>
<td>{tag_mobile}</td>
</tr>
<tr>
<td><a href="mailto:{tag_email}">email me</a></td>
</tr>
</table>
</div>
</div>
</body>
</html>
輝煌!!!這正是我需要的!謝謝Ghommey〜 –