Skip to content

Commit f490934

Browse files
committed
Properly support old IE DOM methods.
1 parent 1c3883b commit f490934

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

doc/index.html

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ <h2>Node.js in the Industry</h2>
9797
document.getElementById('downloadbutton').onclick = function(e) {
9898
e = e || window.event;
9999
e.stopPropagation && e.stopPropagation();
100-
downloadDialogUpdate();
100+
e.cancelBubble = true;
101+
// need to give the hash a tick to update
102+
setTimeout(downloadDialogUpdate, 0);
101103
};
102104

103105
document.getElementById('download-close').onclick =
@@ -110,6 +112,7 @@ <h2>Node.js in the Industry</h2>
110112
document.getElementById('download').onclick = function(e) {
111113
e = e || window.event;
112114
e.stopPropagation && e.stopPropagation();
115+
e.cancelBubble = true;
113116
};
114117

115118
// I keep expecting <Esc> to close the dialog...
@@ -123,11 +126,20 @@ <h2>Node.js in the Industry</h2>
123126
// hacky workaround for old ie browsers that don't support :target css.
124127
function downloadDialogUpdate () {
125128
var div = document.getElementById('download');
129+
if (!div) return;
126130
var expect = location.hash === '#download' ? 'block' : 'none';
127-
var m = div.getComputedStyle || div.currentStyle || null;
128-
if (!m) return;
129-
var actual = m.call(div, 'display');
130-
if (actual !== expect) div.style.diplay = expect;
131+
var actual = div.currentStyle ? div.currentStyle.display
132+
: window.getComputedStyle
133+
? document.defaultView.getComputedStyle(div, null).getPropertyValue('display')
134+
: null;
135+
136+
// it looks like a string, but it might not actually be a string.
137+
// explicitly cast for MSIE 6 and 7.
138+
actual = '' + actual;
139+
expect = '' + expect;
140+
if (actual !== expect) {
141+
div.style.display = expect;
142+
}
131143
}
132144
downloadDialogUpdate();
133145
})();</script>

0 commit comments

Comments
 (0)