开发者

Auto Size Embed Code

Hey, I'm just w开发者_StackOverflow中文版ondering what code I could use to auto change the size of the video being embedded before it gets displayed.

Example, I need to have it find all instances of this

width="any value" height="any value"

and replace them with this

width="540" height="405"


How exactly are you embedding the video? There are javascript libraries such as swfobject or jQuery Media that allow you to set the height/width of a flash object when the page loads.

Alternatively you could use a little bit of jQuery to alter the height/width attributes after the fact.

$('object').attr('height', 405);
$('object').attr('width', 540);


Or you could just wrap them in a common div. Class it with something like .videoWrap

then you could simply style it as:

.videoWrap object, .videoWrap embed{
    width:540px;
    height:405px;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜