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 8560687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:20:00+00:00 2026-06-11T16:20:00+00:00

I have tried: var url = ‘/files/123.txt’; $(‘a’).click(function(e) { e.preventDefault(); //stop the browser from

  • 0

I have tried:

var url = '/files/123.txt';
$('a').click(function(e) {
    e.preventDefault();  //stop the browser from following
    window.location.href = url;
});

This just makes firefox browse to the text file, and not prompt a download.

I have also tried this function:

var downloadURL = function downloadURL(url)
{
    var iframe;
    iframe = document.getElementById("hiddenDownloader");
    if (iframe === null)
    {
        iframe = document.createElement('iframe');  
        iframe.id = "hiddenDownloader";
        iframe.style.visibility = 'hidden';
        document.body.appendChild(iframe);
    }
    iframe.src = url;   
}

Which has the same problem — opens in browser, no download prompt.

I have tried using apache:

<Files *.txt>
  ForceType applicaton/octet-stream
</Files>

I placed a .htaccess with this code in both the subfolder and parent folder. This apache method only seems to work if the requested text file is in the same folder as the web page. When the text file is placed into subfolder /files/, then the same problem persists — no download prompt.

Really now, is there a secret way to do this?

  • 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-06-11T16:20:01+00:00Added an answer on June 11, 2026 at 4:20 pm

    If you want to use the .htaccess way it’s the headers you need to change rather than the content type:

    <FilesMatch "\.(?i:txt)$">
      Header set Content-Disposition attachment
    </FilesMatch>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: $('#refresh').click(function () { alert($('.report-container').length); $('.report-container').each(function () { var accordian
i have class named Group i tried to test configuration: var cfg = new
I have var row=<tr><td>val</td><td>val2</td></tr> and I tried this: $(#mainTable tbody).append(row); but it appends to
I have tried to append <option> inside <select> using javascript by parsing data from
I have tried upgrading from jQuery 1.2.6 to 1.4.1. A JSON query is now
I have tried some tips I was given on regards URL encoding but I
function ObjectProvider() { this.url = ajax/inbounds.php this.inBounds = function () { this.removeMarkers(); var url_string
Have tried to find solutions for this and can't really come up with anything.
I have tried to go through the jungle (really, PayPal, why don't you weed
I have tried searching over the internet about this problem but not able to

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.