1
以下腳本在Firefox中正常工作,但在IE 8中崩潰且出現「未知運行時錯誤」錯誤。使用YUI更改IE 8中的腳本標記的內容
YUI().use('node', function (Y) {
if (Y.one('#testel') == null) {
Y.one('head').append(Y.Node.create('<script id="testel" />'));
}
Y.one('#testel').set('text', 'Wish this would work in IE!');
console.log(Y.one('#testel').get('text'));
});
我與它玩耍了像IE嘗試新事物:「意外的調用方法或屬性訪問」
Y.one('#testel').set('innerHtml', 'Wish this would work in IE!');
Y.one('#testel').set('html', 'Wish this would work in IE!');
Y.one('#testel').setContents('Wish this would work in IE!');
唯一的區別是,有時它賦予了更多有用的錯誤,這導致我認爲腳本標記的文本不能在IE中更改?
雖然四處搜索,但在處理IE中的表格元素時發現了很多對上述問題的引用,但這些情況下的解決方法似乎並不適用於腳本標記。
有什麼辦法可以在IE中實現上述功能嗎? (我只在IE 8中測試過,但我認爲問題在6,7中是一樣的)。
謝謝!