この場合、サイトは IE6 でのみ表示できる内部 Web サイトです。目標は、IE9 で表示できるようにすることです。xml データ アイランドの使用、ドット表記によるドキュメント要素へのアクセスなど、IE のみの適切なスクリプトがいくつかありますresulttable.style.display = "block";
。
Web サイト全体に、非常に大きくてデバッグが難しい JavaScript メソッドが多数あります。参考までに、それぞれ平均約 1000 行の 100 以上の JS ファイルがあります。
以下は、すべての名前/ロジックを省略した実際のメソッドです。すべての戻り値は、前のロジックに依存しています。
function someMethod() {
if (stuff) {
// operations
if (stuff) {
// operations
for (loop) {
// operations
if (stuff) {
// operations
if (stuff) {
// operations
for (loop) {
if (stuff) {
// operations
}
}
// operations
}
else {
// operations
if (stuff) {
// operations
} else {
// operations
}
}
// operations
}
}
// operations
if (stuff) {
// operations
if (stuff) {
// operations
if (stuff) {
// operations
for (stuff) {
// operations
if (stuff) {
// operations
} else {
// operations
}
}
if (stuff) {
// operations
if (stuff) {
// operations
for (loop) {
// operations
}
// operations
for (loop) {
if (stuff) {
// operations
}
}
}
// operations
if (stuff) {
// operations
}
return something;
}
else {
// operations
return something;
}
}
else {
// operations
if (stuff) {
// operations
return something;
}
else {
// operations
if (stuff) {
// operations
}
// operations
return something;
}
}
}
}
return something;
}
else {
// operations
return something;
}
}
return something;
}
レガシー Web サイトを扱う場合、JavaScript メソッドをより管理しやすい部分に分割するためのアドバイスはありますか?
免責事項: 私の JS スキルセットは平均的なものです。そして、当面は JQuery を避けたいと思います。