CSS のいくつかの場所に、次のようなエントリがあります。
button {
background-image: url('../images/button.png');
}
images/
すべてのbackground-image
URLのすべての出現を次のようなものに変更する jQuery の関数が必要です。
button {
background-image: url('../images/Customer/button.png');
}
私は現在、この恐ろしいコードでそれを行っていますが、jQuery を使用するもっときちんとした方法があると思います。イメージの実際の場所は に保持されていることに注意してくださいsessionStorage
。
// Hacks all CSS styles that refer to the images folder.
for ( s = 0; s < document.styleSheets.length; s++ ) {
var mysheet=document.styleSheets[s];
var myrules=mysheet.cssRules? mysheet.cssRules: mysheet.rules;
// Look for: background-image: url(images/button.png);
for (i=0; i < myrules.length; i++){
var css = myrules[i].style.cssText;
if(css.indexOf('images/') != -1 ){
// Surgery on the cssText because the individual entries are read only.
// Replace the css.
myrules[i].style.cssText = css.replace("images/", sessionStorage.images);
// That's the new style.
}
}
}