Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6173095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:30:28+00:00 2026-05-23T23:30:28+00:00

using this mark up and script I can create drag file to desktop links

  • 0

using this mark up and script I can create “drag file to desktop” links for Google Chrome 8.0.552.237 OSX (yay!). My issue us that I cannot specify the name of the dynamically created script file- Google Chrome ALWAYS calls it “download.js” even though I have specified it should be called “customFileName.js”.

Can anyone give me some guidance? Is this a bug, or am I doing something wrong? I know dynamically creating binary files in the browser is probably the wrong side of the bleeding edge and I should be happy that it works at all, but being able to name the files would be of a lot of use to the particular application that I’m building. Source code is commented- thanks in advance 🙂

<!DOCTYPE html>
<html>
    <head></head>
    <body>
        <script>

            var mimeType= 'text/javascript'
            ,   javaScript= 'alert("hello");'
                // convert javascript to binary string
            ,   binaryText= btoa(javaScript)
                // create data uri
            ,   dataUri= "data:text/javascript;charset=utf-8;base64," + binaryText
                // a conventional http url pointing to an image
            ,   resourceUri= 'http://www.chromium.org/_/rsrc/1220198801738/'
                           + 'config/app/images/customLogo/customLogo.gif?revision=2'

                // drag this link to your desktop or other folder and 
                // Google Chrome will download a file to that location 
                // called "download.js" - it should be called "customFileName.js"
            ,   draggableScriptAnchor= document.createElement('a')

                // drag this link to your desktop or other folder and 
                // Google Chrome will download a file to that location 
                // called "customFileName.gif" as expected
            ,   draggableResourceAnchor=document.createElement('a')

            // setup drag to desktop

            // set this anchors href to the data uri
            draggableScriptAnchor.href= dataUri;
            draggableScriptAnchor.innerText= 'Drag dynamic script';
            // listen for drag events
            draggableScriptAnchor.addEventListener
            (
                'dragstart'

            ,   function (mouseEvent)
                {
                    mouseEvent.dataTransfer.setData
                    (
                        "DownloadURL"
                        // note that the convention for this string is
                        // mimetype:filename:url and that the "file"
                        // is given the name "customFileName.js"
                    ,   "text/javascript:customFileName.js:" + dataUri
                    )
                }

            ,   false    
            );

            // set this anchors href to a conventional http url
            draggableResourceAnchor.href= resourceUri
            draggableResourceAnchor.innerText= "Drag image";

            // listen for drag events
            draggableResourceAnchor.addEventListener
            (
                'dragstart'

            ,   function (mouseEvent)
                {
                    mouseEvent.dataTransfer.setData
                    (
                        "DownloadURL"
                        // as above, except that this time the mimetype
                        // is image/gif and the file name is customFileName.gif
                        // THIS WORKS AS EXPECTED
                    ,   "image/gif:customFileName.gif:" + resourceUri
                    )
                }
            )

            // add elements to the DOM
            document.body.appendChild(draggableScriptAnchor);
            document.body.appendChild(document.createElement('br'));
            document.body.appendChild(draggableResourceAnchor);
        </script>
    </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:30:29+00:00Added an answer on May 23, 2026 at 11:30 pm

    It seems to be a bug in Chrome. The issue “Drag and drop of ‘DownloadURL’ type ignores specified filename for data URLs” has been fixed recently, should probably be fixed in Chrome version 13.

    If someone wants to test, check this live example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this script to display all the images in a folder, but I
I am using this HTML <html> <head> <Title>EBAY Search</title> </head> <script language=JavaScript src=ajaxlib.js></script> <body>
Using this question as the base is there an alogrithm or coding example to
Since I have started using this site, I keep hearing about the Boost library.
I've been using this nifty LINQ to SQL tool for a data access layer
anyone have any experience using this? if so, is it worth while?
I'm using this code, to make a request to a given URL: private static
Should I be using this method of throwing errors: if (isset($this->dbfields[$var])) { return $this->dbfields[$var];
I am using this - otherwise excellent - vb tab control in one of
I am using this command: cut -d: -f2 To sort and reedit text, Is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.