Download of file through javascript anonymously without knowledge of user

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ponvijaya
    New Member
    • May 2007
    • 19

    Download of file through javascript anonymously without knowledge of user

    Hi All,

    I have one requirement...

    Its like a search engine design.

    I will have a text box to type in the search text and a search button on clicking which the search action should take place.

    I need to download a text file from the server to the user machine on clicking the search button and i have to do some manipulation by reading the contents of that downloaded text file ... But download of file should happen anonymously without the knowledge of user..

    Please help me...

    Thanks in advance...
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Changed the thread title to add more information.

    Why not do the manipulation on the server-side? Why is it necessary to download the file?

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Heya, ponvijaya.

      Honestly, would YOU want a website to be able to download and open a file on your computer without your knowledge?

      Comment

      • JeremyMiller
        New Member
        • Sep 2007
        • 69

        #4
        Assuming that you're trying to provide information to the user while they're typing or just after clicking the search button, you should look at Ajax as a technique. This allows you to retrieve information -- not to save it as a file, but to retrieve it and then to parse it. This is similar to what Google does when typing to suggest terms you may want to search for.

        Comment

        • rnd me
          Recognized Expert Contributor
          • Jun 2007
          • 427

          #5
          here a simple way to download a text file:

          [code=javascript]


          function IO(U, V) {
          X = !window.XMLHttp Request ? new ActiveXObject(' Microsoft.XMLHT TP') : new XMLHttpRequest;
          X.open(V ? 'PUT' : 'GET', U, !1);
          X.setRequestHea der('Content-Type', 'text/html')
          X.send(V ? V : '');
          return X.responseText; }

          alert(IO("text1 .txt"));[/CODE]


          to save a text file with the contents of a string:[CODE=javascript]
          IO("text1.txt" , "hello world this is javascript")[/code]

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            Heya, Rnd.

            Please use CODE tags when posting source code:

            [CODE=JavaS cript]
            JavaScript code goes here.
            [/CODE]

            Comment

            • rnd me
              Recognized Expert Contributor
              • Jun 2007
              • 427

              #7
              Originally posted by pbmods
              Heya, Rnd.

              Please use CODE tags when posting source code:

              [CODE=JavaScript]
              JavaScript code goes here.
              [/CODE]
              well i had tried, but i hate the line number that get inserted when any of the code formats are applied; it makes it hard to cut and paste!

              is there a way around the problem?

              Comment

              • pbmods
                Recognized Expert Expert
                • Apr 2007
                • 5821

                #8
                Heya, rnd.

                Originally posted by rnd me
                is there a way around the problem?
                Simply click the 'Reply' button, and you can copy the code without line numbers.

                Comment

                Working...