本文介绍了需要ActiveXobject的跨浏览器替代方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

您好我正在使用此代码片段

Hi I am using this code fragment

var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.OpenTextFile(dir + "modules.txt", 2, true, -2);
s.WriteLine(tobewritten);
s.Close();
fso = s = null;
//alert (s);
if (s = "null")
    alert("Records updated");
window.location.href = 'main.html';



这对 IE 。但我需要一个解决方案,让它在 Firefox 中运行。我该怎么办


This is working fine with IE. But I need a solution to get it worked in Firefox. What should I do

推荐答案

引用:
try {
    // test to see if XMLHttpRequest is defined
    XMLHttpRequest.DONE;
}
catch (e) {
    XMLHttpRequest = new Object();
    // define also all the constants
    XMLHttpRequest.UNSENT = 0;
    XMLHttpRequest.OPENED = 1;
    XMLHttpRequest.HEADERS_RECEIVED = 2;
    XMLHttpRequest.LOADING = 3;
    XMLHttpRequest.DONE = 4;
}

/** Creates new instance of the XMLHttpRequest object */
XMLHttpRequest.newInstance = function() {
    var xmlHttp = null;
    // use the ActiveX control for IE5.x and IE6
    try {
        xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
    } catch (othermicrosoft){
        try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (native) {
            // If IE7, Mozilla, Safari, etc: Use native object
            xmlHttp = new XMLHttpRequest();
        }
    }

    return xmlHttp;
};


这篇关于需要ActiveXobject的跨浏览器替代方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 13:07