Current location: Hot Scripts Forums » General Web Coding » JavaScript » download file instead of browsing to it


download file instead of browsing to it

Reply
  #1 (permalink)  
Old 11-28-05, 12:09 AM
nassau nassau is offline
Wannabe Coder
 
Join Date: May 2004
Posts: 211
Thanks: 0
Thanked 0 Times in 0 Posts
download file instead of browsing to it

is there a way for a javascript to let the user download a file instead of browsing to it when a link is clicked?

for example, when clicking on a link for an mp3 file, it will open and play in the browser.

can javascript be used to force the file to download instead of opening?

thanks
Reply With Quote
  #2 (permalink)  
Old 12-01-05, 02:12 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
I don't think JS can be used to force the browser to download the file instead of opening it. That depends on the browser.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #3 (permalink)  
Old 12-02-05, 10:26 AM
nassau nassau is offline
Wannabe Coder
 
Join Date: May 2004
Posts: 211
Thanks: 0
Thanked 0 Times in 0 Posts
check the download link on the right side of this page
http://expert.no-ip.org/?ajax

i haven't been able to use that for myself yet but it seems like proof of concept.
Reply With Quote
  #4 (permalink)  
Old 12-02-05, 10:45 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
^^ Is PHP forced as well, little mix with Javascript tho!

Code:
<script type="text/javascript">
function down(ct, tp, nm){
	window.location.href = '?down='+ct+'&type='+tp+'&name='+nm;
}
Reply With Quote
  #5 (permalink)  
Old 12-02-05, 11:16 AM
nassau nassau is offline
Wannabe Coder
 
Join Date: May 2004
Posts: 211
Thanks: 0
Thanked 0 Times in 0 Posts
yea i know, i just realized it must be in php. i'm reading thru the appropriate php pages at php.net now.... it seems javascript has very little to do with it

thanks
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
Information collector on file download cramerdy Script Requests 0 09-05-05 04:21 PM
File download protector/Information collector cramerdy PHP 10 09-03-05 09:25 AM
Upload Download File Management stiletto PHP 0 03-16-05 06:22 PM
download one file at a time xp17 PHP 0 08-17-04 08:44 PM
file download problem ukyankee Perl 6 10-04-03 10:39 PM


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