zoukankan      html  css  js  c++  java
  • 同时支持 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();
                })
            }
    
        });
    });
    冯瑞涛
  • 相关阅读:
    密码学浅析
    FireWall Mark + LVS
    tcp/ip首部
    iptables(二)网络防火墙
    BIND服务
    LVS(一)
    QQ、微信消息轰炸
    LVS四种模型(二)
    安装和克隆
    压缩和打包
  • 原文地址:https://www.cnblogs.com/finehappy/p/1539396.html
Copyright © 2011-2022 走看看