更改< object>高度和宽度适用于Chrome,但不能使用Firefox或IE。为什么? [英] Changing <object> height and width works in Chrome but not Firefox or IE. Why?

查看:384
本文介绍了更改< object>高度和宽度适用于Chrome,但不能使用Firefox或IE。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作两个YouTube视频的网站。这些视频使用Youtube中的原始嵌入代码。该网站的设计不适用于任何默认的YouTube大小,因此我正在编写代码以自动调整视频大小。这是我的代码页面上永远不会有这两个标签,否则我会更好地选择视频。

 < ; 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

这篇关于更改&lt; object&gt;高度和宽度适用于Chrome,但不能使用Firefox或IE。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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