전역 스타일 시트를 변경하려면 jquery globalcss 플러그인을 사용하고 있습니다. 불투명도와 IE는 처리하지 않습니다.jquery globalcss IE opacity
나는 운이 좋게 작동하도록 노력해 왔습니다. 다음은 플러그인이 IE 스타일의 불투명도를 이해하도록하려는 시도입니다.
function changeCss (property, value, target) {
if (property === "opacity") {
$(target).globalcss("filter","alpha(opacity="+value*100+")");
/* For IE 8 (and 9, 10, 11?). Don't miss the added quotes */
$(target).globalcss("-MS-filter","\"progid:DXImageTransform.Microsoft.Alpha(Opacity="+value*100+")\"");
}
$(target).globalcss(property,value);
}
어쩌구. 누구든지 도울 수 있다면, 좋을 것입니다. 감사.
/*
* Global Stylesheet jQuery Plugin
* Version: 0.1
*
* Enables CSS modification that uses a 'global' stylesheet, rather than inline CSS.
*
* Copyright (c) 2009 Jeremy Shipman (http://www.burnbright.co.nz)
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* INSTRUCTIONS:
* use in the same way as the jQuery css function. Eg:
* $("some selector").globalcss("style","value");
*
* use the globalsetylesheet.print() function to return a string of the global stylesheet
*/
(function($) {
//global singleton class for
globalstylesheet = new function globalStylesheet(){
if(!document.styleSheets){
alert("document.Stylesheets not found");
return false;
}
var sheet = null;
var setrules = Array(); // rule cache
//set up a dummy noded
var cssNode = document.createElement('style');
cssNode.type = 'text/css';
cssNode.rel = 'stylesheet';
cssNode.media = 'screen';
cssNode.title = 'globalStyleSheet';
document.getElementsByTagName("head")[0].appendChild(cssNode);
//find the newly created stylesheet and store reference
for(var i = 0; i < document.styleSheets.length; i++){
if(document.styleSheets[i].title == "globalStyleSheet"){
sheet = document.styleSheets[i];
}
}
//set a CSS rule
this.setRule = function setRule(selector,ruleText){
if(setrules[selector] != undefined){
return setrules[selector];
}else{
if(sheet.addRule){ // IE
sheet.addRule(selector,ruleText,0);
}else{
sheet.insertRule(selector+'{'+ruleText+'}',0);
}
setrules[selector] = this.getRule(selector);
}
return setrules[selector];
}
//get a saved CSS rule
this.getRule = function getRule(selector){
if(setrules[selector] != undefined){
return setrules[selector];
}else{
var rules = allRules();
for(var i = 0; i < rules.length; i++){
if(rules[i].selectorText == selector){
return rules[i];
}
}
}
return false;
}
//helper function to get all rules
function allRules(){
if(sheet.cssRules){ //IE
return sheet.cssRules;
}else{
return sheet.rules;
}
}
//print out the stylesheet
this.print = function print(){
var styleinfo = "";
var rules = allRules();
for(var i = 0; i < rules.length; i++){
styleinfo+= rules[i].cssText+"\n"
}
return styleinfo;
}
//use jQuery's css selector function to set the style object
this.css = function css(jquery,key,value){
rule = this.setRule(jquery.selector,key+":"+value+";");
jQuery(rule).css(key,value);
}
}
//hook new function into jQuery
jQuery.fn.extend({
globalcss : function globalcss(key,value){
globalstylesheet.css(this,key,value);
}
});
})(jQuery);
편집 : 더 이상 원래의 사이트이기 때문에
나는 여기에 플러그인을 붙여없는거야 내가 jsbin 라이브 데모를 만들었습니다. 다른 브라우저에서 비교해보십시오. http://jsbin.com/iqadu/edit
이것을 수행 한 후에 IE6/7에서'elemntid.style.filter'의 값은 무엇입니까? 여기서'elementid'는 당신이 테스트 한 요소의 id입니다. –
또한 'elementid.style.filter'를 사용하여 수동으로 필터를 설정하고 결과를 게시하십시오. –