我試圖凍結我最近2天的GridView標題,並得到了this鏈接和許多其他鏈接也提供給我在Stackoverflow以及谷歌搜索。這工作得很好,當我使用它在IE 6,7和IE8下的兼容模式下,但在正常模式下,此代碼無法正常工作。Javascript的setExpression對我來說是最大的問題。任何解決方案來解決這個問題
這條線給我一個錯誤。我想要實現這個功能。
trs[x].style.setExpression("top", "this.parentElement.parentElement.parentElement.scrollTop + 'px'");
在閱讀評論時,我開始知道scrollableTable.js使用setExpression方法,該方法已在IE8中折舊。
以前我對這個問題一無所知。我希望會有一些替代setExpression方法。
如何與其他一些替代替代setExpression方法在此代碼
功能ScrollableTable(tableEl,tableHeight,tableWidth){
this.initIEengine = function() {
this.containerEl.style.overflowY = 'auto';
if (this.tableEl.parentElement.clientHeight - this.tableEl.offsetHeight < 0) {
this.tableEl.style.width = this.newWidth - this.scrollWidth + 'px';
} else {
this.containerEl.style.overflowY = 'hidden';
this.tableEl.style.width = this.newWidth + 'px';
}
if (this.thead) {
var trs = this.thead.getElementsByTagName('tr');
for (x = 0; x < trs.length; x++) {
trs[x].style.position = 'relative';
trs[x].style.setExpression("top", "this.parentElement.parentElement.parentElement.scrollTop + 'px'");
}
}
if (this.tfoot) {
var trs = this.tfoot.getElementsByTagName('tr');
for (x = 0; x < trs.length; x++) {
trs[x].style.position = 'relative';
trs[x].style.setExpression("bottom", "(this.parentElement.parentElement.offsetHeight - this.parentElement.parentElement.parentElement.clientHeight - this.parentElement.parentElement.parentElement.scrollTop) + 'px'");
}
}
eval("window.attachEvent('onresize', function() { document.getElementById('" + this.tableEl.id + "').style.visibility = 'hidden'; document.getElementById('" + this.tableEl.id + "').style.visibility = 'visible'; })");
};
我對jquery也沒有任何想法。你能否提供一些相同的表達方式? – 2010-09-16 09:00:57