More problems with update site in chrome
diff --git a/samples/index.html b/samples/index.html
index 911ff32..2be0980 100644
--- a/samples/index.html
+++ b/samples/index.html
@@ -1,43 +1,76 @@
<html>
<head>
-<script>
-function loadXMLDoc(dname)
-{
-if (window.XMLHttpRequest)
- {
- xhttp=new XMLHttpRequest();
- }
-else
- {
- xhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
-xhttp.open("GET",dname,false);
-xhttp.send("");
-return xhttp.responseXML;
-}
-
-function displayResult()
-{
-xml=loadXMLDoc("site.xml");
-xsl=loadXMLDoc("web/site.xsl");
-// code for IE
-if (window.ActiveXObject)
- {
- ex=xml.transformNode(xsl);
- document.getElementById("data").innerHTML=ex;
- }
-// code for Mozilla, Firefox, Opera, etc.
-else if (document.implementation && document.implementation.createDocument)
- {
- xsltProcessor=new XSLTProcessor();
- xsltProcessor.importStylesheet(xsl);
- resultDocument = xsltProcessor.transformToFragment(xml,document);
- document.getElementById("data").appendChild(resultDocument);
- }
-}
+<title>Samples</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<style>@import url("web/site.css");</style>
+<script type="text/javascript">
+ var returnval = 0;
+ var stylesheet, xmlFile, cache, doc;
+ function init(){
+ // NSCP 7.1+ / Mozilla 1.4.1+ / Safari
+ // Use the standard DOM Level 2 technique, if it is supported
+ if (document.implementation && document.implementation.createDocument) {
+ xmlFile = document.implementation.createDocument("", "", null);
+ stylesheet = document.implementation.createDocument("", "", null);
+ if (xmlFile.load){
+ xmlFile.load("site.xml");
+ stylesheet.load("web/site.xsl");
+
+ xmlFile.addEventListener("load", transform, false);
+ stylesheet.addEventListener("load", transform, false);
+
+ } else { /////////////////////// THIS IS THE FIX ///////////////////////
+ //alert("Document could not be loaded by browser.");
+ // Chrome
+ var xmlhttp = new window.XMLHttpRequest();
+ xmlhttp.open("GET","site.xml",false);
+ xmlhttp.send(null);
+ xmlFile = xmlhttp.responseXML.documentElement;
+
+ xmlhttp.open("GET","web/site.xsl",false);
+ xmlhttp.send(null);
+ stylesheet = xmlhttp.responseXML.documentElement;
+
+ // I HAVE TO CALL TWICE THIS FUNCTION, BECAUSE IT HAS A COUNTER THAT MUST BE 2 (THIS MAY BE FIXED TOO)
+ transform();
+ transform();
+ } /////////////////////////// END OF THE FIX ///////////////////////////
+
+ }
+ //IE 6.0+ solution
+ else if (window.ActiveXObject) {
+ xmlFile = new ActiveXObject("msxml2.DOMDocument.3.0");
+ xmlFile.async = false;
+ xmlFile.load("site.xml");
+ stylesheet = new ActiveXObject("msxml2.FreeThreadedDOMDocument.3.0");
+ stylesheet.async = false;
+ stylesheet.load("web/site.xsl");
+ cache = new ActiveXObject("msxml2.XSLTemplate.3.0");
+ cache.stylesheet = stylesheet;
+ transformData();
+ }
+ }
+ // separate transformation function for IE 6.0+
+ function transformData(){
+ var processor = cache.createProcessor();
+ processor.input = xmlFile;
+ processor.transform();
+ data.innerHTML = processor.output;
+ }
+ // separate transformation function for NSCP 7.1+ and Mozilla 1.4.1+
+ function transform(){
+ returnval+=1;
+ if (returnval==2){
+ var processor = new XSLTProcessor();
+ processor.importStylesheet(stylesheet);
+ doc = processor.transformToDocument(xmlFile);
+ document.getElementById("data").innerHTML = doc.documentElement.innerHTML;
+ }
+ }
</script>
</head>
-<body onload="displayResult()">
-<div id="data"></div>
+<body onload="init();">
+<!--[insert static HTML here]-->
+<div id="data"><!-- this is where the transformed data goes --></div>
</body>
-</html>
\ No newline at end of file
+</html>