更改< object>高度和宽度适用于Chrome,但不能使用Firefox或IE。为什么? [英] Changing <object> height and width works in Chrome but not Firefox or IE. Why?
问题描述
< ; script language ='JavaScript'type ='text / javascript'>
var x = document.getElementsByTagName('object');
x。[0] .width ='350';
x。[0] .height ='350';
x。[1] .width ='350';
x。[1] .height ='350';
< / script>
为了参考,以下是代码可能会改变的默认的Youtube嵌入示例:
< object width =480height =385>
< param name =movievalue =http://www.youtube-nocookie.com/v/zSgiXGELjbc&hl=zh_CN&fs=1&rel=0>< / param>
< param name =allowFullScreenvalue =true>< / param>
< param name =allowscriptaccessvalue =always>< / param>
< embed src =http://www.youtube-nocookie.com/v/zSgiXGELjbc&hl=zh_CN&fs=1&rel=0type =application / x-shockwave-flashallowscriptaccess =alwaysallowfullscreen =truewidth =480height =385>< / embed>
< / object>
在Chrome中,视频播放器完全位于350x350的框中。在IE和FF(最新版本)中,视频不变,正常大小。 Google找不到任何东西可以解释为什么这不行。我已经尝试使用setattribute,for循环,调整双引号和单引号和双引号等。
任何想法出了什么问题?
firefox使用'embed'中的值不仅仅是'object'标签的值 - 可能需要替换两者来确保
I am making a site with two Youtube videos. These videos use the raw embed code from Youtube. The site's design doesn't work with any of the default Youtube sizes, so I am writing code to automatically resize the video. Here is my code. There will never be more than these two tags on the page, otherwise I'd do a better job selecting the videos.
<script language='JavaScript' type='text/javascript'>
var x=document.getElementsByTagName('object');
x.[0].width='350';
x.[0].height='350';
x.[1].width='350';
x.[1].height='350';
</script>
For reference, here's a sample default Youtube embed that the code might alter:
<object width="480" height="385">
<param name="movie" value="http://www.youtube-nocookie.com/v/zSgiXGELjbc&hl=en_US&fs=1&rel=0"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube-nocookie.com/v/zSgiXGELjbc&hl=en_US&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed>
</object>
In Chrome, the video players sit perfectly in a 350x350 box. In IE and FF (latest versions), the videos are the unchanged, normal size. I cannot find anything in Google that explans why this won't work. I have tried using setattribute, for loops, adjusting both and , single-quotes and double-quotes, etc.
Any ideas what is going wrong?
firefox uses the values in the 'embed' not just values the 'object' tag - probably need to replace both to be sure
这篇关于更改< object>高度和宽度适用于Chrome,但不能使用Firefox或IE。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!