点击按钮后加载闪光灯 [英] Load a flash after hitting a button

查看:130
本文介绍了点击按钮后加载闪光灯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果你点击一个叫做play的按钮,一个弹出窗口/ Modal将会出现在Flash或统一插件游戏。我的问题是,当访问者加载页面时,他们会自动加载Flash文件。这意味着音乐将开始和页面将加载(所有这些游戏)缓慢。



是否有一种方法来加载Flash Player后,有人击中播放按钮?



非常感谢!

解决方案

使用嵌入元素(不需要外部API):

 <!DOCTYPE html> 
< html>
< head>
< title>< / title>
< meta http-equiv =Content-Typecontent =text / html; charset = UTF-8>
< script type =text / javascript>
var flashEmbed = null;
函数startFlash(){
if(flashEmbed!= null){
document.getElementById(flashContainer)。removeChild(flashEmbed);
}
flashEmbed = document.createElement(embed);
document.getElementById(flashContainer)。appendChild(flashEmbed);
flashEmbed.src =Flashfile.swf;
flashEmbed.type =application / x-shockwave-flash;
}
< / script>
< / head>
< body>
< button onclick =startFlash()>开始闪光< /按钮>
< div id =flashContainer>< / div>
< / body>
< / html>


I am building a website with my school work (dreamfoxgames.com).

If you click on a button called "play" a popup/Modal will come with the game in flash or unity plugin. My problem is that when a visitor loads the page they will automatic load the flash file. This means that the music will start and the page will be slow with loading (all those games).

Is there a way to only load the flash player after somebody hit the play button?

Thanks a lot!

解决方案

It can also be done using an embed element (no need for external api):

<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
    var flashEmbed = null;
    function startFlash() {
    if(flashEmbed != null) {
        document.getElementById("flashContainer").removeChild(flashEmbed);
    }
    flashEmbed = document.createElement("embed");
    document.getElementById("flashContainer").appendChild(flashEmbed);
    flashEmbed.src="Flashfile.swf";
    flashEmbed.type="application/x-shockwave-flash";
    }
</script>
</head>
<body>
<button onclick="startFlash()">start flash</button>
<div id="flashContainer"></div>
</body>
</html>

这篇关于点击按钮后加载闪光灯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆