swfobject.embedSWF 不执行任何操作。我缺少什么?

发布于 2024-12-07 10:04:36 字数 1135 浏览 0 评论 0原文

我正在尝试使用 swfObject 在我的网站上嵌入 Flash 视频播放器。这是我的代码的一些片段:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>

<script type="text/javascript">

if (typeof ARI == 'undefined')
{
     ARI = {};
}

ARI.InsertFlash = function()
{
    var flashvars = {};
    var parameters = {};
    parameters.quality = 'high';
    parameters.play = 'true';
    parameters.LOOP = 'false';
    parameters.wmode = 'transparent';
    parameters.allowScriptAccess='true';

    var attributes = {};

    attributes.id='ARIVID';

    swfobject.embedSWF("AS3MediaPlayer.swf","inlieu","720","405","9.0.0","",flashvars,parameters);
    }
</script>

...

<body>
<div class='inlieu'>
       <p> this will be replaced</p>
</div>
<button type='button' onclick='ARI.insertFlash();'>Insert</button>

这没有任何作用。我的按钮确实达到了正确的功能(请原谅页面上可能出现的任何 html 错误)。我已经用 div 测试过了。函数本身确实会触发,但我的 div 没有被替换。我在这里缺少什么?我想嵌入一个使用外部接口的 Flash 对象,因此对我的问题的任何答案都会有帮助。另外,我希望它在用户按下按钮时触发,而不是在页面加载时触发,就像互联网上的大多数示例所示。

谢谢阿里

I am experimenting with with swfObject to embed a flash video player on my site. here is some snippets of my code:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>

<script type="text/javascript">

if (typeof ARI == 'undefined')
{
     ARI = {};
}

ARI.InsertFlash = function()
{
    var flashvars = {};
    var parameters = {};
    parameters.quality = 'high';
    parameters.play = 'true';
    parameters.LOOP = 'false';
    parameters.wmode = 'transparent';
    parameters.allowScriptAccess='true';

    var attributes = {};

    attributes.id='ARIVID';

    swfobject.embedSWF("AS3MediaPlayer.swf","inlieu","720","405","9.0.0","",flashvars,parameters);
    }
</script>

...

<body>
<div class='inlieu'>
       <p> this will be replaced</p>
</div>
<button type='button' onclick='ARI.insertFlash();'>Insert</button>

This does nothing. my button does hit the correct function (please excuse any html errors that might be on the page). I've tested that with a div. The function itself does fire, but my div doesn't get replaced. What am I missing here? I want to embed a flash object that uses external interface, so any answers to my question that keeps that in context would be helpful. Also i want this to fire when a user pushes the button, not on page load, like most of the examples on the internet show.

thanks

Ari

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

似梦非梦 2024-12-14 10:04:36

SWFObject 需要目标元素上的 ID,您正在使用一个类。将 class='inlieu' 更改为 id='inlieu'

另外,由于您在属性中指定了 ID,因此您的新对象将具有 ID ARIVID并且不会继承IDinlieu

<body>
<div id='inlieu'>
   <p> this will be replaced</p>
</div>
<button type='button' onclick='ARI.insertFlash();'>Insert</button>

将变成这样

<body>
<object id="ARIVID" ... ></object>
<button type='button' onclick='ARI.insertFlash();'>Insert</button>

SWFObject requires an ID on the target element, You're using a class. Change class='inlieu' to id='inlieu'

Also, since you're specifying an ID in the attributes, your new object will have the ID ARIVID and will NOT inherit the ID inlieu

This

<body>
<div id='inlieu'>
   <p> this will be replaced</p>
</div>
<button type='button' onclick='ARI.insertFlash();'>Insert</button>

will become this

<body>
<object id="ARIVID" ... ></object>
<button type='button' onclick='ARI.insertFlash();'>Insert</button>
一瞬间的火花 2024-12-14 10:04:36

嗯,您正在从 http://ajax.googleapis.com/ajax 加载 swfobject /libs/swfobject/2.2/swfobject.js
将文件放在与 swf/html 相同的域中,您的问题就会消失。
除了试图窃取带宽之外,您没有理由从谷歌加载,如果他们决定用新的东西更新该代码库,这可能会导致您的版本问题。

此外,您应该按照您的说明在 onLoad 或单击按钮中调用该函数。您发布的代码在页面完成加载之前运行,并且来自 google 的 javascript 文件可能尚未加载。
您可以通过将此代码放在嵌入语句之前来测试这一点。

alert( swfobject );

um you are loading swfobject from http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js
Put the file in the same domain as your swf/html and your issue should go away.
Aside from trying to steal bandwidth you have no reason to loading from google and this can cause you version issues, if they decide to update that code base with something new.

Also you should be calling that function onLoad or from a button click as you stated. The code you posted is running before the page is finished loading and that javascript file from google may not be loaded yet.
You can test this by putting this code right before the embed statement.

alert( swfobject );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文