且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Ajax通过jQuery加载SWF文件

更新时间:2023-12-05 09:17:58

使用 swfobject 加载swf并在需要时调用它.


jQuery.ajax 回调上加载swf的完整示例将是

Use swfobject to load the swf and call it whenever you like.


A full fledged example on loading the swf on an jQuery.ajax callback will be
<script type="text/javascript" src="https://www.google.com/jsapi?key=INSERT-YOUR-KEY">    </script>
<script type="text/javascript">
    google.load("jquery", "1.5.1");
    google.load("swfobject", "2.2");
</script>
<script type="text/javascript">
    $.ajax({
        url: "some url",
        context: document.body,
        success: function (msg) {
            LoadSWF();
        }
    });
    function LoadSWF(someData) {
        var flashvars = {
            name1: "hello",
            name2: "world",
            name3: "foobar"
        };
        var params = {
            menu: "false"
        };
        var attributes = {
            id: "myDynamicContent",
            name: "myDynamicContent"
        };

        swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
    }
</script>