Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/425.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用javascript或html更改flash嵌入大小?_Javascript_Html_Flash - Fatal编程技术网

用javascript或html更改flash嵌入大小?

用javascript或html更改flash嵌入大小?,javascript,html,flash,Javascript,Html,Flash,我正在尝试将此视频缩放到640x360。当我改变宽度和高度时,视频不会变大。我尝试添加参数scale=“aspect”、scale=“exactfit”、scale=“default”。他们都没有工作 有没有办法将其扩展到640x360 嵌入代码: <object width="416" height="374" classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000"> <param name="allowscriptaccess"

我正在尝试将此视频缩放到640x360。当我改变宽度和高度时,视频不会变大。我尝试添加参数scale=“aspect”、scale=“exactfit”、scale=“default”。他们都没有工作

有没有办法将其扩展到640x360

嵌入代码:

<object width="416" height="374" classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="allowscriptaccess" value="always" />
<param name="movie" value="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" />
<embed src="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" type="application/x-shockwave-flash" allowscriptaccess="always" width="416" height="374">
</embed>
</object>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<object width="416" height="374" classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="allowscriptaccess" value="always" />
<param name="movie" value="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" />
<embed src="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" type="application/x-shockwave-flash" allowscriptaccess="always" width="416" height="374">
</embed>
</object>

<script>
function testcode () {
    $('object').attr('width','640');
    $('object').attr('height','500');

    $('object embed').attr('width','640');
    $('object embed').attr('height','500');
}

</script>

<br>
<a href="#" onclick="testcode()">click to test</a>
<html>
<head><title>SWF example by jQuery</title></head>
<body>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<object width="416" height="374" classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="allowscriptaccess" value="always" />
<param name="movie" value="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" />
<embed src="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" type="application/x-shockwave-flash" allowscriptaccess="always" width="416" height="374">
</embed>
</object>

<script>
function testcode () {
    $('object').attr('width','640');
    $('object').attr('height','500');

    $('object embed').attr('width','640');
    $('object embed').attr('height','500');
}

</script>

<br>
<a href="#" onclick="testcode()">click to test</a>

</body>
</html>

这也不起作用:

<object width="416" height="374" classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="allowscriptaccess" value="always" />
<param name="movie" value="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" />
<embed src="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" type="application/x-shockwave-flash" allowscriptaccess="always" width="416" height="374">
</embed>
</object>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<object width="416" height="374" classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="allowscriptaccess" value="always" />
<param name="movie" value="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" />
<embed src="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" type="application/x-shockwave-flash" allowscriptaccess="always" width="416" height="374">
</embed>
</object>

<script>
function testcode () {
    $('object').attr('width','640');
    $('object').attr('height','500');

    $('object embed').attr('width','640');
    $('object embed').attr('height','500');
}

</script>

<br>
<a href="#" onclick="testcode()">click to test</a>
<html>
<head><title>SWF example by jQuery</title></head>
<body>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<object width="416" height="374" classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="allowscriptaccess" value="always" />
<param name="movie" value="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" />
<embed src="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" type="application/x-shockwave-flash" allowscriptaccess="always" width="416" height="374">
</embed>
</object>

<script>
function testcode () {
    $('object').attr('width','640');
    $('object').attr('height','500');

    $('object embed').attr('width','640');
    $('object embed').attr('height','500');
}

</script>

<br>
<a href="#" onclick="testcode()">click to test</a>

</body>
</html>

函数testcode(){
$('object').attr('width','640');
$('object').attr('height','500');
$('object embed').attr('width','640');
$('object embed').attr('height','500');
}

显示为:


您可以使用以下jQuery脚本:

$(window).resize(function(){


    $('object').attr('width','640');
    $('object').attr('height','360');

    $('object embed').attr('width','640');
    $('object embed').attr('height','360');

});
请参阅上的结果

你可以用。嵌入Flash内容是一种易于使用且标准友好的方法,它使用一个小的JavaScript文件

编辑:

<object width="416" height="374" classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="allowscriptaccess" value="always" />
<param name="movie" value="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" />
<embed src="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" type="application/x-shockwave-flash" allowscriptaccess="always" width="416" height="374">
</embed>
</object>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<object width="416" height="374" classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="allowscriptaccess" value="always" />
<param name="movie" value="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" />
<embed src="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" type="application/x-shockwave-flash" allowscriptaccess="always" width="416" height="374">
</embed>
</object>

<script>
function testcode () {
    $('object').attr('width','640');
    $('object').attr('height','500');

    $('object embed').attr('width','640');
    $('object embed').attr('height','500');
}

</script>

<br>
<a href="#" onclick="testcode()">click to test</a>
<html>
<head><title>SWF example by jQuery</title></head>
<body>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<object width="416" height="374" classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="allowscriptaccess" value="always" />
<param name="movie" value="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" />
<embed src="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" type="application/x-shockwave-flash" allowscriptaccess="always" width="416" height="374">
</embed>
</object>

<script>
function testcode () {
    $('object').attr('width','640');
    $('object').attr('height','500');

    $('object embed').attr('width','640');
    $('object embed').attr('height','500');
}

</script>

<br>
<a href="#" onclick="testcode()">click to test</a>

</body>
</html>

jQuery提供的SWF示例
函数testcode(){
$('object').attr('width','640');
$('object').attr('height','500');
$('object embed').attr('width','640');
$('object embed').attr('height','500');
}


您可以使用以下jQuery脚本:

$(window).resize(function(){


    $('object').attr('width','640');
    $('object').attr('height','360');

    $('object embed').attr('width','640');
    $('object embed').attr('height','360');

});
请参阅上的结果

你可以用。嵌入Flash内容是一种易于使用且标准友好的方法,它使用一个小的JavaScript文件

编辑:

<object width="416" height="374" classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="allowscriptaccess" value="always" />
<param name="movie" value="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" />
<embed src="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" type="application/x-shockwave-flash" allowscriptaccess="always" width="416" height="374">
</embed>
</object>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<object width="416" height="374" classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="allowscriptaccess" value="always" />
<param name="movie" value="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" />
<embed src="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" type="application/x-shockwave-flash" allowscriptaccess="always" width="416" height="374">
</embed>
</object>

<script>
function testcode () {
    $('object').attr('width','640');
    $('object').attr('height','500');

    $('object embed').attr('width','640');
    $('object embed').attr('height','500');
}

</script>

<br>
<a href="#" onclick="testcode()">click to test</a>
<html>
<head><title>SWF example by jQuery</title></head>
<body>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<object width="416" height="374" classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="allowscriptaccess" value="always" />
<param name="movie" value="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" />
<embed src="http://i.cdn.turner.com/cnn/.element/apps/cvp/3.0/swf/cnn_416x234_embed.swf?context=embed&videoId=us/2011/10/28/dnt-mom-learns-death-thru-facebook.wsyr" type="application/x-shockwave-flash" allowscriptaccess="always" width="416" height="374">
</embed>
</object>

<script>
function testcode () {
    $('object').attr('width','640');
    $('object').attr('height','500');

    $('object embed').attr('width','640');
    $('object embed').attr('height','500');
}

</script>

<br>
<a href="#" onclick="testcode()">click to test</a>

</body>
</html>

jQuery提供的SWF示例
函数testcode(){
$('object').attr('width','640');
$('object').attr('height','500');
$('object embed').attr('width','640');
$('object embed').attr('height','500');
}


查看要嵌入的.swf文件的url。该大小在所有.swf文件中都是硬编码的。


这只是其中之一,但那个尺寸是硬编码的。我想如果你知道actionscript,你可以参与其中,但我不知道。也许你可以做到,实际上你可以,我只是不知道如何使用javascript

查看要嵌入的.swf文件的url。该大小在所有.swf文件中都是硬编码的。


这只是其中之一,但那个尺寸是硬编码的。我想如果你知道actionscript,你可以参与其中,但我不知道。也许你可以做到,实际上你可以,我只是不知道如何使用javascript

问题在于您正在调整浏览器/DOM的嵌入元素的大小,但实际上没有缩放嵌入的内容(Flash动画)

查看您正在引用的SWF URL:
cnn\u 416x234\u embed.SWF
。动画硬编码为416x234,无论您对周围的HTML做了什么,都将以该大小播放

有几种方法可以满足您的需求:

a) 找到一个CNN嵌入URL,该URL被编译成您想要的大小640x360。然后,只需将HTML嵌入元素硬编码为该大小(除非有其他原因需要使用Javascript)

b) 打开Flash,创建一个“动画”,将CNN SWF加载到一个帧中,并将其缩放到您想要的大小。保存并导出到SWF,并将此动画嵌入到页面中

c) Flash完全可以通过ActionScript编写脚本(Javascript和ActionScript都只是ECMAscript),而且由于您已经设置了
allowscriptaccess=“always”
,因此您应该能够使用Javascript操纵动画。在调试器中运行CNN SWF,找出需要调整大小的元素,并缩放它们

解决方案(a)显然是最简单和最好的,假设它存在的话,因为您希望使用的视频实际上是按照您想要的大小编码的,而不是416px宽的编码,然后进行缩放。就我个人而言,如果这不起作用,我真的不同意将视频缩放1.5倍,那就不好看了

编辑/添加:请参见下面我的评论。由于跨域问题,不幸的是,答案是不可能操纵第三方SWF(本例中为CNN)内对象的大小。如果这是您的SWF,或者在中启用了跨域访问,则建议的解决方案将起作用。但在这种情况下,CNN的SWF被锁定,不允许跨域访问


所以,不幸的是,答案是如果CNN不发布你想要的大小的视频小部件(我的(a)解决方案),你就走运了,对不起。你不可能做你想做的事。我将在这里留下完整的答案,以防它对其他人有所帮助。

问题是您正在调整浏览器/DOM的嵌入元素的大小,但实际上没有缩放嵌入的内容(Flash动画)

查看您正在引用的SWF URL:
cnn\u 416x234\u embed.SWF
。动画硬编码为416x234,无论您对周围的HTML做了什么,都将以该大小播放

有几种方法可以满足您的需求:

a) 找到一个CNN嵌入URL,该URL被编译成您想要的大小640x360。然后,只需将HTML嵌入元素硬编码为该大小(除非有其他原因需要使用Javascript)

b) 打开Flash,创建一个“动画”,将CNN SWF加载到一个帧中,并将其缩放到您想要的大小。保存并导出到SWF,并将此动画嵌入到页面中

c) Flash完全可以通过ActionScript编写脚本(Javascript和ActionScript都只是ECMAscript),而且由于您已经设置了
allowscriptaccess=“always”
,因此您应该能够使用Javascript操纵动画。在调试器中运行CNN SWF,找出需要调整大小的元素,并缩放它们

解决方案(a)显然是最简单和最好的,假设它存在的话,因为您希望使用的视频实际上是按照您想要的大小编码的,而不是416px宽的编码,然后进行缩放。就我个人而言,如果这不起作用,我真的不同意将视频缩放1.5倍,那就不好看了

编辑/添加:请参见下面我的评论。由于跨域问题,不幸的是,答案是不可能操纵对象的大小