0

How to download a file from a url with Javascript?

I'm trying to get from a textfield a user enters a url as follows:

new Ext.form.TextField({
                disabled: false,
                        fieldLabel: "file",
                        value:'',
            id:"url"};

and I need the value of this variable is the file contained in the above url I am trying as follows:

var file1 = new OpenLayers.WPS.ComplexPut({
                      identifier: "file1",
                      value: window.location.href = document.getElementById("url")
Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126
ricardo
  • 7,894
  • 9
  • 26
  • 38

2 Answers2

1

is this done in a browser? If so, you could use Ajax to download plain text or XML. Save yourself a lot of trouble and learn jQuery first, and it'll be quite easy.

geon
  • 7,581
  • 3
  • 32
  • 40
1

You can use jQuery to load anything from an URL quite easily with:

<script>
   $("#loadhere").load("http://www.google.com");
</script>
elasticrat
  • 6,940
  • 5
  • 35
  • 36