0
我點擊圖片時會加載一個視頻,問題是視頻不會自動播放,因此您必須點擊兩次。我希望此視頻在點擊圖片時自動播放。在此先感謝使用swfobject自動啓動swf視頻
<tr>
<td class="filmbodyplay" height="50" align="right" valign="top">
<a href="#" onclick="playMovie(this, 'https://www.capcomfcu.org/images/stories/security-center/swf/phishing.swf');" >
<img src="https://www.capcomfcu.org/images/stories/security-center/phishing.jpg" border="0" alt="play" />
</a>
</td>
</tr>
<script type="text/javascript">
swfobject.registerObject("FlashID");
</script>
頭碼
<script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
<script type="text/javascript">
function playMovie(a, href) {
// remove element if exists
var container = document.getElementById("playing");
var flash_movie = document.getElementById("flash_movie");
if(flash_movie) {
container.removeChild(flash_movie);
}
// create new element
var embed = document.createElement("EMBED");
embed.setAttribute("allowFullScreen", "true");
embed.setAttribute("autostart", "true");
embed.setAttribute("src", href);
embed.setAttribute("type", "application/x-shockwave-flash");
embed.setAttribute("width", "480");
embed.setAttribute("height", "360");
embed.setAttribute("id", "flash_movie");
// clear out the cell
cell = a.parentNode;
cell.id = 'playing';
while(cell.hasChildNodes()) {
cell.removeChild(cell.firstChild);
}
// insert the element into the cell
cell.appendChild(embed);
}
</script>
我嘗試使用自動啓動,自動播放,播放,似乎沒有任何工作。我意識到做到這一點的最佳方式是創建預加載器,但我無法訪問原始Flash文件。我只有這個SWF文件和我有限的JavaScript知識 – user2733112