Needed help with javascript - javascript

So guys I am working on a program to like download stuff using javascript. I hav written the following code:
function download()
{
alert("Hello");
var url='http://somesite/somefile.rar';
window.open(url,'Download');
}
The code is pretty easy, but is there some other way to download the file using javascript? Also having downloaded the file is there some way to store it locally in the location of our choice, like d-drive? I had come across the javascript file api while searching the web, is it any useful in my scenario? Please help.
Edit: Fixed code formatting

No, this isn't possible. It is up to the client where to save files, not you.

Through Javascript, you can only set the file name that you want, but would not be able to access the file system i.e. All the folders, etc..

Related

Need ScriptReferenceProfiler.dll or alternate

I improving site performance and for that, I try to Bundle or combine ScriptResource.axd and Webresource.axd but before combine to I need to know javascript file reference name which is used by ajax control toolkit in asp.net web form
like this https://lancezhang.wordpress.com/2008/11/15/aspnet-ajax-performance/
I need ScriptReferenceProfiler.DLL to get a reference of the javascript file which is used in ajax toolkit on the web page.
do you have any idea to get this dll file
I go through this tutorial
https://channel9.msdn.com/Blogs/ASP-NET-Site-Videos/using-script-combining-to-improve-ajax-performance
Or if you have any alternate solution please let me know
The file you looking and reference from the link you add was here : http://aspnet.codeplex.com/releases/view/13356
I can not find it now so I uploaded for you here, both source code and binaries.
http://planethost.gr/so/ScriptReferenceProfiler.zip
http://planethost.gr/so/ScriptReferenceProfilerBinaries.zip

How to Read a Local File Using Node.js

I have a relatively simple task that I want to achieve, but I am totally stumped on how to achieve it. I want to create an HTML page that allows users to select a local JSON file. I want to pass the path to this local file to some Javascript code. Then I want to read that file using Javascript every time the file changes.
I've investigated a few different methods for achieving this. First, I tried just using Javascript. This worked great until I wanted to read the file multiple times as it was changing. Evidently there are security concerns that make this impossible.
Next, I investigated using Node.js to solve this problem. It has some file utilities that seem perfect, and it's server-side, which may help with the security issues. But using just Node, I couldn't figure out how to select a local file in HTML and pass the path to the Javascript code. From investigation online, it seems like Express.js would be useful.
So now I'm trying to use Node.js and Express.js. Now I can figure out the file name from an HTML form! But I can't figure out the path to the local file so that I can read it using the Node file utilities... From looking at similar questions online, it looks like everyone uploads files, then reads them. Is that what I have to do with Express? If so, is it possible for me to monitor changes to the original file, upload the file when those changes get made, then read the changed file? Is what I'm trying to do possible? If so, does anyone have any recommendations on libraries/modules to use? Thank you so much for any help - please let me know if I can be more clear about anything.

Download file with excel-builder.js

I've been trying to use excel-builder.js library to generate and Excel file and download it automatically, just as done here.
Now, I must stress out that I'm rather new to front end development, otherwise I might have figured it out already...
Anyway, what I can't seem to figure out is what is this "downloader" in the example? download is required and downloader is used like magic, but for me it doesn't work (since I don't really know what to require).
Has anyone tried it successfully? Thanks in advance!
OK, sorry for the bother. As I stated, I'm new to this.
I found the relevant code, and like in other places, it has to do with creating an invisible form and submitting it.

Find all images in folder with Javascript

Sorry If this is trivial,
Edit: in short I found out this really isn't intended to be done with client-side JavaScript.
I am wondering if i know a folder has pictures. /home/project1/pictures
and they follow some naming convention face102039.jpg face1030303.jpg ...
Is there a was to know every picture thats in there starting with face but not knowing what numbers are after it? Like is there a way i could possibly grab all the file names with a .jpg or .png extension and then i would know how to parse their strings. I am just not sure how to get all the files in a directory with javascript.
I saw this similar post, and I know how to do what I want in Java, but i couldnt find a way to do this in javascript. I was thinking about doing it server side with java or ruby but I am pretty sure i should be able to do this clientside via javascript. Maybe I am wrong though.
Given the constraints it is technically possible to do this, just not very practical. I would not recommend using this since you could lock up the user's browser pretty quickly.
var len = 2000000;//How long you want to wait.
var pics=[];
for(var i=0;i<len;i++){
a=new Image();
a.onload=function(){
pics.push(this);
}
a.src='/home/project1/pictures/face'+i+'.jpg';
}
The real answer is you need to implement a back end in PHP, RoR, etc. To send you a list of the files in the picture folder. This can be done with AJAX.
Javascript is running at the client side. For example in the browser of the visitor. It has no direct access to the server and image folders, as Java and php does.
What can be done is using ajax in the javascript, to fetch a java/php file which lists the directory content.
You can't access the file system with JavaScript. You could, however, use AJAX to query your server for that information and return it as a JSON string.
Hope this helps.

How to parse a CSV file into an array in Javascript

From what i understand, This usually has to be done server side. However i have read that it is possible to point to the csv file in a .js file. This would be more useful to me as i am not messing around with server side code and stuff for this project and will be all on my local machine. I saw an article with example code to do this somewere however i can't locate that article atm. Anyone know how to do this?
To access any file from the system you have to use directX in IE or read up on how to use NPAPI for mozilla support.If you are willing to use HTML5, check out its filereader API here.

Categories

Resources