• 同时支持 IE 和 Mozilla 浏览器的 javaScript XSLT 代码


    //主机地址
    var hostAddress = "http://localhost/CharDir/";
    //var hostAddress = "Http://192.168.1.23:8080/";
    var currentXMLUrl = "";
    var currentExcelXslUrl = "";
    var currentXslName = "";
    
    var onoff = true;
    
    
    
    //111应付保费 按钮事件
    $(document).ready(function() {
        $('#MPayPremium').click(function() {
    
            if (document.implementation && document.implementation.createDocument) { //
                
    
                // 支持Mozilla浏览器 
                try {
                    xmlDoc = document.implementation.createDocument("", "", null);
                    xmlDoc.async = false;
                    xmlDoc.load(hostAddress + "MPayPremium/Index.xml" + "?time=" + getExcelFileName('a'));
                }
                catch (e) {
                    alert("error:001");
                }
                try {
                    xslDoc = document.implementation.createDocument("", "", null);
                    xslDoc.async = false;
                    xslDoc.load("chartDir/MPayPremium/index.xsl");
                }
                catch (e) {
                    alert("error:002");
                }
                try {
                    // 定义XSLTProcessor对象    
                    var xsltProcessor = new XSLTProcessor();
                    xsltProcessor.importStylesheet(xslDoc);
                    var oResultFragment = xsltProcessor.transformToFragment(xmlDoc, document);
                    // 将解析过的文本输出到页面
                    $('#rightside').html(oResultFragment);
                }
                catch (e) {
                    alert("error:003");
                }  
                
            }
            else if (typeof window.ActiveXObject != 'undefined') { //IE浏览器
    
                // Load XML 
                var xml = new ActiveXObject("Microsoft.XMLDOM")
                xml.async = false
                xml.load(hostAddress + "MPayPremium/Index.xml" + "?time=" + getExcelFileName('a'))
    
                // Load XSL
                var xsl = new ActiveXObject("Microsoft.XMLDOM")
                xsl.async = false
                xsl.load("chartDir/MPayPremium/index.xsl")
    
                $('#rightside').html(xml.transformNode(xsl));
    
    
                $('.divTitle').hover(function() {
                    $(this).addClass('hover');
                }, function() {
                    $(this).removeClass('hover');
                });
    
                $('.divTitle').click(function() {
                    //设置导出XML的地址
                    currentXMLUrl = this.title;
                    //设置导出XML的XSL地址
                    currentExcelXslUrl = "chartDir/MPayPremium/MPayPremiumToExcel.xsl";
                    //设置导出文件的名字
                    currentXslName = this.innerText;
    
                    CallMppTable();
                })
            }
    
        });
    });
    冯瑞涛
  • 相关阅读:
    Redis史上最全文章教程
    一目了然的 Node.js Windows10 安装篇
    maven 报错 Failed to execute goal on project ...: Could not resolve dependencies for project ...
    SpringCloud 的版本问题 (深入)
    shell编程题(二十八)
    shell编程题(二十七)
    shell编程题(二十六)
    C++之Boost Asio相关
    C++之function函数
    C++之正则表达式
  • 原文地址:https://www.cnblogs.com/finehappy/p/1539396.html
Copyright © 2020-2023  润新知