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

  • SEARCH
  • Home
  • 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 269133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:47:18+00:00 2026-05-11T23:47:18+00:00

Is it possible, in Javascript, to prompt user for downloading a file that isn’t

  • 0

Is it possible, in Javascript, to prompt user for downloading a file that isn’t actually on the server, but has contents of a script variable, instead?

Something in spirit with:

var contents = "Foo bar";
invoke_download_dialog(contents, "text/plain");

Cheers,

MH

  • 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-11T23:47:18+00:00Added an answer on May 11, 2026 at 11:47 pm

    javascript: URIs should work for this – indeed, this is exactly what they’re meant for. However, IE doesn’t honour the type attribute, and in Safari this technique has no effect at all.

    data: URIs work in Firefox (3.0.11) and Safari (4.0) (and probably other compliant browsers), but I can’t get this approach to work in IE (8.0). (All tested in Windows)

    <a href="data:text/plain,The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog.">Data URI</a>

    This isn’t a JS solution in itself, but JS can be used to set the href dynamically. Use the escape function to turn raw text/data into URI-encoded form.

    Combining this with detecting IE and using the IE-specific solution already linked to might do what you want….

    I shall add that you can’t force it to trigger a download dialog (that’s beyond the scope of both HTML and JS), but you can persuade it to do so by setting application/octet-stream as the type. Trouble is that the user’ll then have to add the right filename extension manually.

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

Sidebar

Related Questions

Is it possible to generate a file in javascript and then prompt the user
I would like to have a javascript prompt pop up that has a selection
I'd like a short smallest possible javascript routine that when a mousedown occurs on
Possible Duplicate: JavaScript Function Definition in ASP User Control Hi, I have a generic
Possible Duplicate JavaScript: Changing src-attribute of a embed-tag but this is not working for
Using JavaScript SDK, it is possible to wall post with user's consent. Since It
Possible Duplicate: JavaScript: var functionName = function() {} vs function functionName() {} What's the
Possible Duplicate: JavaScript data formatting/pretty printer I am getting a bit tired of looking
Possible Duplicate: JavaScript: Why the anonymous function wrapper? I would like to ask you
Possible Duplicate: javascript: pause setTimeout(); Im using jQuery and working on a notification system

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.