【发布时间】:2009-08-29 16:08:06
【问题描述】:
我已经设法重写了一个脚本,该脚本使图像调整为其父 Div 容器的 100% 宽度到一个脚本,现在允许 Swf 嵌入对象调整大小(原始图像调整脚本由 Oliver Boermans olicle.c o m/eg/jquery/imagefit/)
我所做的只是在 img 标签的参数应该替换宽度和高度值的所有行中用“嵌入”替换 img。
在 Firefox 中一切正常,但在 IE 7 中完全没有运气。
观看在 Firefox 中调整大小的 Flash 视频,而 IE 7 显示错误。
这是我的 jquery js 函数:
(function($) {
$.fn.imagefit = function(options) {
var fit = {
all : function(imgs){
imgs.each(function(){
fit.one(this);
})
},
one : function(img){
$(img)
.width('100%').each(function()
{
$(this).height(Math.round(
$(this).attr('startheight')*($(this).width()/$(this).attr('startwidth')))
);
})
}
};
this.each(function(){
var container = this;
// store list of contained images (excluding those in tables)
var imgs = $('img', container).not($("table img"));
// store initial dimensions on each image
imgs.each(function(){
$(this).attr('startwidth', $(this).width())
.attr('startheight', $(this).height())
.css('max-width', $(this).attr('startwidth')+"px");
fit.one(this);
});
// Re-adjust when window width is changed
$(window).bind('resize', function(){
fit.all(imgs);
});
});
return this;
};
})(jQuery);
每个函数负责遍历我从触发函数调用的所有 div:jQuery(document).ready(function(){ jQuery('.widget-content').flashfit(); });
我怎样才能使它也适用于 Internet Explorer 和 Chrome?有什么想法吗?
【问题讨论】:
-
嘿,我想我在这里回答了这个问题 [关于如何使用 javascript 将 Flash 调整为全屏][1] [1]:stackoverflow.com/questions/7826069/…
标签: jquery flash internet-explorer image resize