Mercurial > hg-website
comparison src/en/javascript/main.js @ 29:18110c461824
js: loading another content if OS is Win
author | Alexander Solovyov <piranha@piranha.org.ua> |
---|---|
date | Mon, 16 Feb 2009 00:04:58 +0200 |
parents | |
children | baf1530ba0b0 |
comparison
equal
deleted
inserted
replaced
28:cbfc4d01da6b | 29:18110c461824 |
---|---|
1 // http://simonwillison.net/2004/May/26/addLoadEvent/ | |
2 function addLoadEvent(func) { | |
3 var oldonload = window.onload; | |
4 if (typeof window.onload != 'function') { | |
5 window.onload = func; | |
6 } else { | |
7 window.onload = function() { | |
8 if (oldonload) { | |
9 oldonload(); | |
10 } | |
11 func(); | |
12 } | |
13 } | |
14 } | |
15 | |
16 var xmlhttp = null; | |
17 | |
18 function loadXMLDoc(url) { | |
19 if (window.XMLHttpRequest) {// code for Firefox, Opera, IE7, etc. | |
20 xmlhttp = new XMLHttpRequest(); | |
21 } else if (window.ActiveXObject) {// code for IE6, IE5 | |
22 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); | |
23 } | |
24 if (xmlhttp != null) { | |
25 xmlhttp.onreadystatechange = stateChange; | |
26 xmlhttp.open("GET",url,true); | |
27 xmlhttp.send(null); | |
28 } else { | |
29 alert("Your browser does not support XMLHTTP."); | |
30 } | |
31 } | |
32 | |
33 function stateChange() { | |
34 if (xmlhttp.readyState==4) {// 4 = "loaded" | |
35 document.getElementById('replace').innerHTML = xmlhttp.responseText; | |
36 } | |
37 } | |
38 | |
39 addLoadEvent(function () { | |
40 if (navigator.appVersion.indexOf("Win")!=-1) { | |
41 loadXMLDoc("win.html"); | |
42 } | |
43 }); |