/    Sign up×
Community /Pin to ProfileBookmark

IS there any way to avoid ActiveXObject in javascript for reading documents ?

In need of desperate guidance

  • 1.

    Is there any way to avoid ActivexObject in JavaScript for reading documents and constructing xmls?

  • 2.

    Actual there is a problem with the client, he doesn’t like the IE security settings like “Access data source across domains” under Miscellaneous and “Run ActiveX controls and plug-ins”.

  • And It should support IE 7, 8 and above. If possible that should work in cross browser also.

    Currently in JavaScript, we are using the below codes:

    var xmlDoc = new ActiveXObject(“MSXML2.DOMDocument”); –>for xml construction.

    var stm = new ActiveXObject(“ADODB.Stream”); –> for reading the doc and docx file from client temporary path.

    What is needed:

  • 1. We need to find an alternate in order to avoid using the ActiveXobject.
  • OR

  • 2. We need to automate the Internet Security Settings in client machine.
  • Could some one help me in this please?

    Thanks
    Nanda

    to post a comment
    JavaScript

    2 Comments(s)

    Copy linkTweet thisAlerts:
    @rootOct 31.2013 — You could have the documents uploaded to the server, have the server parse the file to get the data out, when the client has finished with that file, delete it off the server.

    This all depends on what your objectives are with accessing the data in this way.
    Copy linkTweet thisAlerts:
    @toicontienOct 31.2013 — You could try out Dean Edward's solution: http://dean.edwards.name/weblog/2006/04/easy-xml/

    Basically you create a new element with the tag name set to "xml". Then set the "src" property to the URL of an XML file.

    Another way would be to load the XML document in an IFRAME from a URL in the same domain as the current Web page. As long as the XML document in the IFRAME is in the same domain name as the parent page, JavaScript can access the window and document objects inside the IFRAME, and therefore JavaScript can extract those values.

    Perhaps something like this?

    [CODE]function loadXML(url, callback, context) {
    var iframe = document.createElement("iframe");
    iframe.onload = function() {
    callback.call(context, iframe.contentDocument);
    iframe.onload = null;
    document.body.removeChild(iframe);
    iframe = callback = context = null;
    };

    document.body.appendChild(iframe);

    iframe.src = url;
    }[/CODE]


    You would use it like this:

    [code=html]<script type="text/javascript">

    // Procedural or Functional code:
    loadXML("/data.xml", function(doc) {
    $(doc).find("foo").each(function() {
    // do stuff
    });
    });

    // Object oriented code:
    var someObject = {
    foo: function() {
    loadXML("/data.xml", function(doc) {
    this.extractData(doc);
    }, this); // Notice the third argument: "this" sets the value of "this" in the callback
    },

    extractData: function(doc) {
    $(doc).find("foo").each(function() {
    // do stuff
    });
    }
    };

    </script>[/code]


    [B]Note: This is untested code[/B]
    ×

    Success!

    Help @nnithiyanand spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.4,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...