locked
jscript RRS feed

  • Question

  • i have wrtten a small piece of code to just open a file and reaging one char from it but it is giving no error but alert message after creation of activexobject is not being displayed... can anyonyone help me out.....

     

    code

     

     

     

    void function read1(abc)

    {

    alert("in the fun");

    var variable = abc;

    var objCreatedFile, objOpenedFile;

    var objTextFile;

    var sRead;

    var ForReading = 1, ForWriting = 2, ForAppending = 8;

     

    alert("in the fun1");

    var objFSO = new ActiveXObject("Scripting.FileSystemObject");//not showing the alert message //after this line....

    alert("in the fun1");

    objTextFile =objFSO.OpenTextFile("c:\\logfile.txt",ForReading);

    sRead = objTextFile.Read(1);

    alert("in the fun2");

    }

    Wednesday, May 23, 2007 7:04 AM

Answers

  • The reason for  third alert not coming is that the below statement would result in error because of ActiveXControl settings.

    var objFSO = new ActiveXObject("Scripting.FileSystemObject");//not showing the alert message //after this line....

     

    Please try following.

    Goto Tools -> Internet Options

    Select Security tab.

    And try custom security level for the zone your script would run in.

    Please change ActiveXControl setting for 'Initialise and Script ActiveXControls not marked as safe' from ActiveXControl settings group to either Enable or Promt (preferrable).

     

    Now try running the above script. Let me know if this doesn't help.

     

    Sheetal

    MSFT

    Monday, May 28, 2007 8:09 AM