Chciałem użyć ie expressions w css, żeby poprawić wygląd stron w IE 6 i 7, bo css jak zwykle nie działa na nich jak powinien. Nie znam się zbytnio na expressions, mam napisane coś takiego w pliku ie6.css
.layer .shadow-middle div
{
-ie-xp : expression(
x = this.parentNode.parentNode.offsetHeight,
y = parseInt(this.currentStyle.top),
this.style.height = (x - y) + 'px'
)
}
.layer .shadow-top .center,
.layer .shadow-bottom .center
{
-ie-xp : expression(
x = this.parentNode.parentNode.offsetWidth,
y = parseInt(this.currentStyle.left),
this.style.width = (x - y) + 'px'
)
}
.layer .content .maincontent .mainmenu, .layer .content .maincontent .mainpage {
float : left;
-ie-xp : expression(
this.parse ? 0 : (
this.style.height = this.parentNode.offsetHeight + 'px',
this.parse = 1
),
helper = (this.style.height < this.parentNode.offsetHeight) ? 0 : (
this.style.height = this.previousSibling.offsetHeight
)
);
}
W index.php, w head:
Nawet to działa, ale jest pewnien problem. Mianowicie IE wyświetla błąd (taki jak są błędy js, pokazuje się w lewym dolnym rogu):
Wiersz: 1
Znak: 1
Błąd: Wymagany jest obiekt
Kod: 0
Jak to można naprawić?
Problem rozwiązany. Wybaczcie, ale dopiero się tego uczę :d
Poprawny kod:
```javascript
.layer .shadow-middle div
{
-ie-xp : expression(this.parse ? 0 : (
x = this.parentNode.parentNode.offsetHeight,
y = parseInt(this.currentStyle.top),
this.style.height = (x - y) + 'px'
));
}
.layer .shadow-top .center,
.layer .shadow-bottom .center
{
-ie-xp : expression(this.parse ? 0 : (
x = this.parentNode.parentNode.offsetWidth,
y = parseInt(this.currentStyle.left),
this.style.width = (x - y) + 'px'
));
}
.layer .content .maincontent .mainmenu, .layer .content .maincontent .mainpage {
float : left;
-ie-xp : expression(
this.parse ? 0 : (
this.style.height = this.parentNode.offsetHeight + 'px',
this.parse = 1),
this.parse ? 0 : (
helper = (this.style.height < this.parentNode.offsetHeight) ? 0 : (
this.style.height = this.previousSibling.offsetHeight)
)
);
}
"this.parse ? 0 : ( )" w kilku miejscach pomogło. Nie jestem pewny, czy to działa do sprawdzenia, czy objekt istnieje, ale chyba tak. W każdym razie działa. Ale jakby ktoś wiedział, czy tak się sprawdza czy objekt już powstał, czy jakoś inaczej, to napiszcie