|
37 | 37 | // reside (so you can test it yourself).
|
38 | 38 | //
|
39 | 39 | // jQuery Versions - 1.2.6, 1.3.2, 1.4.1, 1.4.2
|
40 |
| -// Browsers Tested - Internet Explorer 6-8, Firefox 2-4, Chrome 5-6, Safari 3.2-5, |
| 40 | +// Browsers Tested - Firefox 2-4, Chrome 5-6, Safari 3.2-5, |
41 | 41 | // Opera 9.6-10.60, iPhone 3.1, Android 1.6-2.2, BlackBerry 4.6-5.
|
42 | 42 | // Unit Tests - http://benalman.com/code/projects/jquery-hashchange/unit/
|
43 | 43 | //
|
|
267 | 267 | timeout_id = setTimeout(poll, $.fn[str_hashchange].delay);
|
268 | 268 | };
|
269 | 269 |
|
270 |
| - // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv |
271 |
| - // vvvvvvvvvvvvvvvvvvv REMOVE IF NOT SUPPORTING IE6/7/8 vvvvvvvvvvvvvvvvvvv |
272 |
| - // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv |
273 |
| - (window.navigator.userAgent.indexOf("MSIE ") > -1 || !!window.navigator.userAgent.match(/Trident.*rv\:11\./) || navigator.appName == 'Microsoft Internet Explorer') && window.attachEvent && !window.addEventListener && !supports_onhashchange && (function () { |
274 |
| - // Not only do IE6/7 need the "magical" Iframe treatment, but so does IE8 |
275 |
| - // when running in "IE7 compatibility" mode. |
276 |
| - |
277 |
| - var iframe, |
278 |
| - iframe_src; |
279 |
| - |
280 |
| - // When the event is bound and polling starts in IE 6/7, create a hidden |
281 |
| - // Iframe for history handling. |
282 |
| - self.start = function () { |
283 |
| - if (!iframe) { |
284 |
| - iframe_src = $.fn[str_hashchange].src; |
285 |
| - iframe_src = iframe_src && iframe_src + get_fragment(); |
286 |
| - |
287 |
| - // Create hidden Iframe. Attempt to make Iframe as hidden as possible |
288 |
| - // by using techniques from http://www.paciellogroup.com/blog/?p=604. |
289 |
| - iframe = $('<iframe tabindex="-1" title="empty"/>').hide() |
290 |
| - |
291 |
| - // When Iframe has completely loaded, initialize the history and |
292 |
| - // start polling. |
293 |
| - .one('load', function () { |
294 |
| - iframe_src || history_set(get_fragment()); |
295 |
| - poll(); |
296 |
| - }) |
297 |
| - |
298 |
| - // Load Iframe src if specified, otherwise nothing. |
299 |
| - .attr('src', iframe_src || 'javascript:0') |
300 |
| - |
301 |
| - // Append Iframe after the end of the body to prevent unnecessary |
302 |
| - // initial page scrolling (yes, this works). |
303 |
| - .insertAfter('body')[0].contentWindow; |
304 |
| - |
305 |
| - // Whenever `document.title` changes, update the Iframe's title to |
306 |
| - // prettify the back/next history menu entries. Since IE sometimes |
307 |
| - // errors with "Unspecified error" the very first time this is set |
308 |
| - // (yes, very useful) wrap this with a try/catch block. |
309 |
| - doc.onpropertychange = function () { |
310 |
| - try { |
311 |
| - if (event.propertyName === 'title') { |
312 |
| - iframe.document.title = doc.title; |
313 |
| - } |
314 |
| - } catch (e) { } |
315 |
| - }; |
316 |
| - |
317 |
| - } |
318 |
| - }; |
319 |
| - |
320 |
| - // Override the "stop" method since an IE6/7 Iframe was created. Even |
321 |
| - // if there are no longer any bound event handlers, the polling loop |
322 |
| - // is still necessary for back/next to work at all! |
323 |
| - self.stop = fn_retval; |
324 |
| - |
325 |
| - // Get history by looking at the hidden Iframe's location.hash. |
326 |
| - history_get = function () { |
327 |
| - return get_fragment(iframe.location.href); |
328 |
| - }; |
329 |
| - |
330 |
| - // Set a new history item by opening and then closing the Iframe |
331 |
| - // document, *then* setting its location.hash. If document.domain has |
332 |
| - // been set, update that as well. |
333 |
| - history_set = function (hash, history_hash) { |
334 |
| - var iframe_doc = iframe.document, |
335 |
| - domain = $.fn[str_hashchange].domain; |
336 |
| - |
337 |
| - if (hash !== history_hash) { |
338 |
| - // Update Iframe with any initial `document.title` that might be set. |
339 |
| - iframe_doc.title = doc.title; |
340 |
| - |
341 |
| - // Opening the Iframe's document after it has been closed is what |
342 |
| - // actually adds a history entry. |
343 |
| - iframe_doc.open(); |
344 |
| - |
345 |
| - // Set document.domain for the Iframe document as well, if necessary. |
346 |
| - domain && iframe_doc.write('\x3cscript>document.domain="' + domain + '"\x3c/script>'); |
347 |
| - |
348 |
| - iframe_doc.close(); |
349 |
| - |
350 |
| - // Update the Iframe's hash, for great justice. |
351 |
| - iframe.location.hash = hash; |
352 |
| - } |
353 |
| - }; |
354 |
| - |
355 |
| - })(); |
356 |
| - // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
357 |
| - // ^^^^^^^^^^^^^^^^^^^ REMOVE IF NOT SUPPORTING IE6/7/8 ^^^^^^^^^^^^^^^^^^^ |
358 |
| - // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
359 |
| - |
360 | 270 | return self;
|
361 | 271 | })();
|
362 | 272 |
|
|
0 commit comments