温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:狂人论坛3.0源码
当前文件:
W3AWPMNK1EI77/aspnet_client/system_web/1_1_4322/SmartNav.js[8K,2009-6-12 11:57:59],打开代码结构图
W3AWPMNK1EI77/aspnet_client/system_web/1_1_4322/SmartNav.js[8K,2009-6-12 11:57:59],打开代码结构图1<!------------------------------------------------------------------------ 2
// 3
// Copyright 2000 Microsoft Corporation. All Rights Reserved. 4
// 5
// File: SmartNav.js 6
// 7
// Description: this file implements a smart navigation mecanism 8
// 9
//-----------------------------------------------------------------------> 10
11
if (window.__smartNav == null) 12
{ 13
window.__smartNav = new Object(); 14
15
window.__smartNav.update = function() 16
{ 17
var sn = window.__smartNav; 18
var fd; 19
document.detachEvent("onstop", sn.stopHif); 20
sn.inPost = false; 21
try { fd = frames["__hifSmartNav"].document; } catch (e) {return;} 22
var fdr = fd.getElementsByTagName("asp_smartnav_rdir"); 23
if (fdr.length > 0) 24
{ 25
if (sn.sHif == null) 26
{ 27
sn.sHif = document.createElement("IFRAME"); 28
sn.sHif.name = "__hifSmartNav"; 29
sn.sHif.style.display = "none"; 30
} 31
try {window.location = fdr[0].url;} catch (e) {}; 32
return; 33
} 34
var fdurl = fd.location.href; 35
if (fdurl == "javascript:smartnav=1" || fdurl == "about:blank") 36
return; 37
var fdurlb = fdurl.split("?")[0]; 38
if (document.location.href.indexOf(fdurlb) < 0) 39
{ 40
document.location.href=fdurl; 41
return; 42
} 43
if (sn.sHif != null) 44
{ 45
sn.sHif.removeNode(true); 46
sn.sHif = null; 47
} 48
var fd = frames["__hifSmartNav"].document; 49
var hdm = document.getElementsByTagName("head")[0]; 50
var hk = hdm.childNodes; 51
var tt = null; 52
for (var i = hk.length - 1; i>= 0; i--) 53
{ 54
if (hk[i].tagName == "TITLE") 55
{ 56
tt = hk[i].outerHTML; 57
continue; 58
} 59
if (hk[i].tagName != "BASEFONT" || hk[i].innerHTML.length == 0) 60
hdm.removeChild(hdm.childNodes[i]); 61
} 62
var kids = fd.getElementsByTagName("head")[0].childNodes; 63
for (var i = 0; i < kids.length; i++) 64
{ 65
var tn = kids[i].tagName; 66
var k = document.createElement(tn); 67
k.id = kids[i].id; 68
k.mergeAttributes(kids[i]); 69
switch(tn) 70
{ 71
case "TITLE": 72
if (tt == kids[i].outerHTML) 73
continue; 74
k.innerText = kids[i].text; 75
hdm.insertAdjacentElement("afterbegin", k); 76
continue; 77
case "BASEFONT" : 78
if (kids[i].innerHTML.length > 0) 79
continue; 80
break; 81
default: 82
var o = document.createElement("BODY"); 83
o.innerHTML = "<BODY>" + kids[i].outerHTML + "</BODY>"; 84
k = o.firstChild; 85
break; 86
} 87
hdm.appendChild(k); 88
} 89
document.body.clearAttributes(); 90
document.body.id = fd.body.id; 91
document.body.mergeAttributes(fd.body); 92
var newBodyLoad = fd.body.onload; 93
if (newBodyLoad != null) 94
document.body.onload = newBodyLoad; 95
var s = "<BODY>" + fd.body.innerHTML + "</BODY>"; 96
if (sn.hif != null) 97
{ 98
var hifP = sn.hif.parentElement; 99
if (hifP != null) 100
sn.sHif=hifP.removeChild(sn.hif); 101
} 102
document.body.innerHTML = s; 103
var sc = document.scripts; 104
for (var i = 0; i < sc.length; i++) 105
{ 106
sc[i].text = sc[i].text; 107
} 108
sn.hif = document.all("__hifSmartNav"); 109
if (sn.hif != null) 110
{ 111
var hif = sn.hif; 112
sn.hifName = "__hifSmartNav" + (new Date()).getTime(); 113
frames["__hifSmartNav"].name = sn.hifName; 114
sn.hifDoc = hif.contentWindow.document; 115
if (sn.ie5) 116
hif.parentElement.removeChild(hif); 117
window.setTimeout(sn.restoreFocus,0); 118
} 119
if (typeof(window.onload) == "string") 120
{ 121
try { eval(window.onload) } catch (e) {}; 122
} 123
else if (window.onload != null) 124
{ 125
try { window.onload() } catch (e) {}; 126
} 127
sn.attachForm(); 128
}; 129
130
window.__smartNav.restoreFocus = function() 131
{ 132
if (window.__smartNav.inPost == true) return; 133
var curAe = document.activeElement; 134
var sAeId = window.__smartNav.ae; 135
if (sAeId==null || curAe!=null && (curAe.id==sAeId||curAe.name==sAeId)) 136
return; 137
var ae = document.all(sAeId); 138
if (ae == null) return; 139
try { ae.focus(); } catch(e){}; 140
} 141
142
window.__smartNav.saveHistory = function() 143
{ 144
if (window.__smartNav.hif != null) 145
window.__smartNav.hif.removeNode(); 146
if (window.__smartNav.sHif != null) 147
document.all[window.__smartNav.siHif].insertAdjacentElement( 148
"BeforeBegin", window.__smartNav.sHif); 149
} 150
151
window.__smartNav.stopHif = function() 152
{ 153
document.detachEvent("onstop", window.__smartNav.stopHif); 154
var sn = window.__smartNav; 155
if (sn.hif != null) 156
sn.hifDoc = sn.hif.contentWindow.document; 157
if (sn.hifDoc != null) 158
sn.hifDoc.execCommand("stop"); 159
} 160
161
window.__smartNav.init = function() 162
{ 163
var sn = window.__smartNav; 164
document.detachEvent("onstop", sn.stopHif); 165
document.attachEvent("onstop", sn.stopHif); 166
if (sn.form.__InitDone == true) return; 167
sn.form.__InitDone = true; 168
try { if (window.event.returnValue == false) return;} catch(e) {} 169
sn.inPost = true; 170
if (document.activeElement != null) 171
{ 172
var ae = document.activeElement.id; 173
if (ae.length == 0) 174
ae = document.activeElement.name; 175
sn.ae = ae; 176
} 177
else 178
sn.ae = null; 179
try {document.selection.empty();} catch (e) {} 180
181
if (sn.hif == null) 182
{ 183
sn.hif = document.all("__hifSmartNav"); 184
sn.hifDoc = sn.hif.contentWindow.document; 185
} 186
if (sn.hifDoc != null) 187
sn.hifDoc.designMode = "On"; 188
if (sn.hif.parentElement == null) 189
document.body.appendChild(sn.hif); 190
191
var hif = sn.hif; 192
hif.detachEvent("onload", sn.update); 193
hif.attachEvent("onload", sn.update); 194
}; 195
196
window.__smartNav.submit = function() 197
{ 198
window.__smartNav.init(); 199
window.__smartNav.form._submit(); 200
}; 201
202
window.__smartNav.attachForm = function() 203
{ 204
var cf = document.forms; 205
for (var i=0; i<cf.length; i++) 206
{ 207
if (cf[i].__smartNavEnabled != null) 208
{ 209
window.__smartNav.form = cf[i]; 210
break; 211
} 212
} 213
214
var snfm = window.__smartNav.form; 215
if (snfm == null) return false; 216
217
var sft = snfm.target; 218
if (sft.length != 0 && sft.indexOf("__hifSmartNav") != 0) return false; 219
220
var sfc = snfm.action.split("?")[0]; 221
var url = window.location.href.split("?")[0]; 222
if (url.lastIndexOf(sfc) + sfc.length != url.length) return false; 223
if (snfm.__formAttached == true) return true; 224
225
snfm.__formAttached = true; 226
snfm.attachEvent("onsubmit", window.__smartNav.init); 227
snfm._submit = snfm.submit; 228
snfm.submit = window.__smartNav.submit; 229
snfm.target = window.__smartNav.hifName; 230
return true; 231
}; 232
233
window.__smartNav.hifName = "__hifSmartNav" + (new Date()).getTime(); 234
window.__smartNav.ie5 = navigator.appVersion.indexOf("MSIE 5") > 0; 235
var rc = window.__smartNav.attachForm(); 236
var hif = document.all("__hifSmartNav"); 237
if (rc) 238
{ 239
var fsn = frames["__hifSmartNav"]; 240
fsn.name = window.__smartNav.hifName; 241
window.__smartNav.siHif = hif.sourceIndex; 242
try { 243
if (fsn.document.location != "javascript:smartnav=1") 244
{ 245
fsn.document.designMode = "On"; 246
hif.attachEvent("onload",window.__smartNav.update); 247
window.__smartNav.hif = hif; 248
} 249
} 250
catch (e) { window.__smartNav.hif = hif; } 251
window.attachEvent("onbeforeunload", window.__smartNav.saveHistory); 252
} 253
else 254
window.__smartNav = null; 255
} 256
257





window.__smartNav 
}
}