Current location: Hot Scripts Forums » General Web Coding » JavaScript » Can you retrieve file list from url using Javascript?


Can you retrieve file list from url using Javascript?

Reply
  #1 (permalink)  
Old 05-05-05, 03:34 PM
tommyb tommyb is offline
New Member
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Question Can you retrieve file list from url using Javascript?

Hello all,

Is it possible to determine the file contents of a URL location using Javascript?

I'd like to dynamically fetch a list of image files from a specific URL location, then load each image and scroll them across the screen using DHTML techniques.

I could require file names be increasing numerically so I could try to blindly load "1.jpg", "2.jpg", etc., until a load attempt failed, but I would prefer to be able to dump any image file in my target location and have the images scroll across the screen.

Thanks in advance for any response!

Tom
Reply With Quote
  #2 (permalink)  
Old 05-06-05, 11:54 AM
abraxxas's Avatar
abraxxas abraxxas is offline
Newbie Coder
 
Join Date: Apr 2005
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Shouldn't be a problem.
Write the file name in a querystring:
www.mysite.com/mypage.htm?file=img.jpg

Then fetch the entire url with javascript using window.location.href and remove evertying but the last part. I figure it'd look something like

Code:
var url = window.location.href;
var filename = url.substring(url.indexOf('?file=')+6,url.length);
__________________
Will work for bandwidth
Reply With Quote
  #3 (permalink)  
Old 05-06-05, 02:28 PM
tommyb tommyb is offline
New Member
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks abraxxas! I'm not sure if I didn't explain clearly enough or I don't understand your reply. Please bear with me in either case!

I'm wondering if javascript has the ability to retrieve a list of available files from a specified location on the web, then parse those files and preload any image files that were found into a scrolling marquee. This will allow me to upload images without being concerned with their name or having to update the javascript code.

I haven't found any js example where a list of files in a directory are retrieved from the server. The only examples I've found used .asp or php.

If you understood me but I was being dense, please elaborate. I'm a C++ developer just getting into website stuff. Even though I don't know a lot about this at the moment, I will hopefully be a quick learner!
Reply With Quote
  #4 (permalink)  
Old 05-06-05, 02:51 PM
abraxxas's Avatar
abraxxas abraxxas is offline
Newbie Coder
 
Join Date: Apr 2005
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Being accustomed to c++, you'll have an easy time learning C# on the microsoft .NET platform. That's what I recommend for ya when you eventually decide to go serverside.

I'm afraid I'll have to say I doubt your wish can be achieved with JavaScript, though. And essentially, this is one of many reasons why you do want to build dynamical (serverside) websites in the first place - to rid you the effort of updating scripts manually.
__________________
Will work for bandwidth
Reply With Quote
  #5 (permalink)  
Old 05-06-05, 03:24 PM
tommyb tommyb is offline
New Member
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
It turns out that this is possible, at least on Microsoft Windows systems.

Check out these links:

http://gethelp.devx.com/techtips/web.../10min0599.asp

http://www.webreference.com/js/column71/

Thanks again for your help.

Tom
Reply With Quote
  #6 (permalink)  
Old 05-06-05, 03:55 PM
abraxxas's Avatar
abraxxas abraxxas is offline
Newbie Coder
 
Join Date: Apr 2005
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Well, the first link is actually ASP (VB Script), and the second is ActiveX embedded in a JavaScript, which is poorly supported. But granted, I wasn't aware that you could use the FileSystemObject wit ActiveX and that doubtlessly is a way to achieve what you want, although, as you've pointed out yourself, only to some visitors.
__________________
Will work for bandwidth
Reply With Quote
  #7 (permalink)  
Old 05-06-05, 03:58 PM
tommyb tommyb is offline
New Member
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Agreed. I'll be staying away from this method due to compatibility issues.

However, I do believe that it further confirms this type of operation isn't possible with js alone. Otherwise, there wouldn't be a need for articles of this type!

Tom
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
retrieve information from MYSQL through drop down list minglou PHP 3 04-03-09 09:43 PM
Retrieve a list of value from a datagrid. MistyJoy Visual Basic 0 01-05-05 08:02 PM
Can javascript be used to read and write to a text file kept on a webserver? gmb1994 JavaScript 4 11-23-04 10:50 AM
Javascript and external.vbs file fs22 JavaScript 0 03-31-04 03:35 PM
Upload file to table so ONLY files tied to primary key are displayed in record? grafixDummy PHP 4 12-20-03 04:28 PM


All times are GMT -5. The time now is 10:47 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.