i search google and got a code snippet for downloading file by jquery. the syntax is like below
var downloadURL = function(url)
{
var iframe;
iframe = document.getElementById("hiddenDownloader");
if (iframe === null)
{
iframe = document.createElement('iframe');
iframe.id = "hiddenDownloader";
iframe.style.visibility = 'hidden';
document.body.appendChild(iframe);
}
iframe.src = url;
}
but could not understand how it works. how call it and how to pass url. so please help me to use the above function and tell me how to pass url as argument. please also tell me what type of code is the above it is not a function.
var downloadURL = function(url)
how it works. variable name equal to function name. a function can be called but the above code snippet can not be called. so please discuss in detail. thanks.
Your sample code is an equivalent to doing this:
Therefore you can call the function this way:
Now, what the function is doing is creating an iframe element in the page and setting the address to the url passed as argument, this will make the browser to show the download dialog for that file.
Hope this makes it clear.