Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Jun 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    File Download using JAVASCRIPT

    Can anyone give me the code for the following:

    Suppose there is a hyperlink for file downloading in a html document. If I click on the link a new pop up window will come up which will be in the form of a typical file download popup window and will ask me to either "open" or "save" or "cancel" or "more info" (just as it happens in a typical file download process where a file download popup is being thrown).

    Also my file(the file can be in any format---.doc,.pdf,.exe or whatever)resides in my local hard drive and when I click on the hyper link the file download popup will comeup and will give me the 4 options as mentioned above.It wont just display the content of the file to be opened in new popup window.It will explicitly give the 4 options for any type of file to be downloaded thru the hyperlink.

    This coding is to be done only and only with HTML and JAVASCRIPT .

    Can anyone help me by providing code for the above task.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    If the file is already located in your local hard drive, then why do you still want to have those options? Why don't you just want the file opened in its associated application or in the browser itself?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New to the CF scene
    Join Date
    Jun 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    File Download using JAVASCRIPT

    Quote Originally Posted by glenngv
    If the file is already located in your local hard drive, then why do you still want to have those options? Why don't you just want the file opened in its associated application or in the browser itself?

    Actually the necessity is like that only...........even if the file is in my local hard disk I want those 4 options to come up in case of any file types. Please help me in this regard.....its urgent.

    Here may I reiterate again that the coding is to be done using HTML and javascriot only........noting else sud be used

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You need a server-side language for this. Javascript can't do it.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by sudipta
    This coding is to be done only and only with HTML and JAVASCRIPT.
    is that because it is a college project, one which isn't remotely realistic?
    *keep it simple (TM)

  • #6
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by sudipta View Post
    Can anyone give me the code for the following:

    Suppose there is a hyperlink for file downloading in a html document. If I click on the link a new pop up window will come up which will be in the form of a typical file download popup window and will ask me to either "open" or "save" or "cancel" or "more info" (just as it happens in a typical file download process where a file download popup is being thrown).

    Also my file(the file can be in any format---.doc,.pdf,.exe or whatever)resides in my local hard drive and when I click on the hyper link the file download popup will comeup and will give me the 4 options as mentioned above.It wont just display the content of the file to be opened in new popup window.It will explicitly give the 4 options for any type of file to be downloaded thru the hyperlink.

    This coding is to be done only and only with HTML and JAVASCRIPT .

    Can anyone help me by providing code for the above task.



    Did you get solution for this? if you have the solution, please share it..Thanks

  • #7
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    The answer was clearly given in Post #4.

  • #8
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,373
    Thanks
    11
    Thanked 591 Times in 572 Posts
    Quote Originally Posted by Philip M View Post
    The answer was clearly given in Post #4.
    i wouldn't be so fast to dismiss. If they know the exact path, you can point to the file and open it in a new window. If the file is something like an html file, it won't offer the download options.

    If the page is served from the same folder as the file, then you can easily ajax the file, and window.open the responseText as a dataURL.

    if you only need any browser to do it from a public site, firefox3 will let you open the local file via a file input, and again, open the data as a dataURL in a new window.

    Since dataURLs let you specify the mimeType, you can force the download box by using a fake mimeType.

    so, in general, and perhaps most correctly, the answer is "no", but in some cases, it can be done under the right conditions.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%

  • #9
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Quote Originally Posted by rnd me View Post
    i wouldn't be so fast to dismiss. .....
    so, in general, and perhaps most correctly, the answer is "no", but in some cases, it can be done under the right conditions.
    The OP required
    This coding is to be done only and only with HTML and JAVASCRIPT .

  • #10
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,373
    Thanks
    11
    Thanked 591 Times in 572 Posts
    Quote Originally Posted by Philip M View Post
    The OP required
    This coding is to be done only and only with HTML and JAVASCRIPT .
    what's your point?

    it's not like i offered a flash solution or anything...
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •