MS过滤器添加与jQuery [英] MS Filters added with jquery
问题描述
我工作的一个项目和任务之一就是使背景的静态和覆盖整个页面。关于本我发现本教程,使用真棒,很简单,进CSS3路 。我的问题是,我有更多的页面,每个人都有不同的背景,所以我必须把背景图像上<身体GT;
是这样的:
<车身风格=背景图像:网址(图像/ mainBg_1.jpg);>
(也css样式放在<身体GT;
,而不是HTML,就像例子)
正如你可以在链接看到,有IE浏览器,如:
过滤器:进程id:DXImageTransform.Microsoft.AlphaImageLoader(SRC ='**。** myBackground.jpg',sizingMethod ='规模');
-ms过滤器进程id:DXImageTransform.Microsoft.AlphaImageLoader(SRC ='** ** myBackground.jpg',sizingMethod ='规模');
问题是,myBackground.jpg从&LT服用;身体GT;
标签,正如我上面写的,所以我不能直接在CSS写(每页面有不同的背景)。
有没有一种方式来增加使用jQuery这些过滤器?我成功地把从体内图像的路径,所以我只需要将其粘贴在此code,然后用jQuery的增加对IE< = 8
谢谢您的回答,跟着他们我成功解决了我的问题。所以,如果有人想在code:
$(函数(){
VAR亩= $ .browser;
如果(mu.msie&放大器;&放大器; mu.version&10 9){ 。VAR的curBg = $('HTML')ATTR('风格');
的curBg = curBg.split('(');
的curBg =的curBg [1] .split(')'); $('HTML')。CSS({
过滤器:进程id:DXImageTransform.Microsoft.AlphaImageLoader(SRC ='+的curBg [0] +',sizingMethod ='规模'),
-ms过滤器:进程id:DXImageTransform.Microsoft.AlphaImageLoader(SRC ='+的curBg [0] +',sizingMethod ='规模')
}); }
});
您可以使用$('身体')。CSS()或$('身体')。ATTR()和改变身体的样式属性。
I'm working on a project and one of tasks is to make the background static and cover whole page. About this I found this tutorial, using "Awesome, Easy, Progressive CSS3 Way". My problem is that I have more pages and each has a different background so I have to put the background image on <body>
like this:
<body style="background-image:url(images/mainBg_1.jpg);">
(also the css style is put on <body>
, not on "html", like in example)
As you can see in that link, there are filters for IE, like this:
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='.**myBackground.jpg**', sizingMethod='scale');
-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='**myBackground.jpg**', sizingMethod='scale')";
The problem is that "myBackground.jpg" is taken from <body>
tag, as I wrote above, so I can't write directly in css (every page has different background).
Is there a way to add these filters using jQuery? I successfully took the path of the image from body, so I only need to paste it in this code and then add with jQuery for IE <= 8.
Thanks for your answers, following them i succeed to solve my problem. So, if somebody wants the code :
$(function(){
var mu = $.browser;
if (mu.msie && mu.version < 9) {
var curBg = $('html').attr('style');
curBg = curBg.split('(');
curBg = curBg[1].split(')');
$('html').css({
"filter" : "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+curBg[0]+"', sizingMethod='scale')",
"-ms-filter" : "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+curBg[0]+"', sizingMethod='scale')"
});
}
});
You can either use $('body').css() or $('body').attr() and change the style attribute of body.
这篇关于MS过滤器添加与jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!