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 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

Ask A Question

Stats

  • Questions 170k
  • Answers 170k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The subversion FAQ has a discussion on storing repositories on… May 12, 2026 at 2:10 pm
  • Editorial Team
    Editorial Team added an answer I think you can do most of this via WMI… May 12, 2026 at 2:10 pm
  • Editorial Team
    Editorial Team added an answer The bitmap is most likely initialized to be all black.… May 12, 2026 at 2:10 pm

Related Questions

Is it possible, in Javascript, to prompt user for downloading a file that isn't
Background I have a page on my ASP.NET MVC web app for users to
I've written a bookmarklet to look a word up in a Chinese dictionary: javascript:Qr=document.getSelection();if(!Qr){void(Qr=prompt('%E8%AF%8D%E8%AF%AD',''))};if(Qr)(function(){window.open('http://nciku.com/search/all/'+Qr);})();
If you don't want any context or an example of why I need this,
i have a series of rows that are generated using an asp:repeater : <asp:repeater

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.