Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Whenever I click on the download link it just shows me a page of code. I tried in IE8, IE9, FireFox, Chrome, Safari, Opera... In all of them it does this. Why?

Example: Downloading jQuery-1.8.3.js from jquery.com

share|improve this question
    
What download link? Is it a single web site that's affected? Have you tried logging out or restarting? Does it happen on another computer as well? –  Daniel Beck Dec 20 '12 at 20:26
    
@DanielBeck It's like that with every .js or .css file on no-matter what website I'm on. I tried resetting to default settings, I tried reinstalling them all - nothing helps :s –  Daniel Ziga Dec 20 '12 at 20:28
    
So you're using SU right now essentially with JS and CSS disabled? –  Daniel Beck Dec 20 '12 at 20:56
    
I want to make sure I understand. If you click on a link to a JavaScript or CSS file (or enter the address of a JavaScript or CSS file in the address box), all of your browsers show the text of the file. But you want your browsers to show a download prompt instead? If so, I know how to change this in Opera. I (or someone else) might need to research the other browsers. –  Bavi_H Dec 21 '12 at 2:39
add comment

2 Answers

Why is this a problem? This is the default behavior of most browsers. If you need a copy of the .js or .css file, just go to File -> Save as... or the equivalent in your browser.

share|improve this answer
    
+1 , you might also encounter this issue with pdf files, current browsers are capable of rendering a lot of different filetypes –  Shakehar Dec 21 '12 at 4:43
add comment

You can change how Opera handles JavaScript and CSS files that you navigate to directly using these steps:

  1. Go to the Settings (or Tools) menu, Preferences command, Advanced tab, Downloads category.
  2. Uncheck "Hide file types opened with Opera".
  3. In the Quick find box, type text/
  4. Select the item you want to edit.
    On my computer I see text/css is for CSS files and text/javascript and text/ecmascript are for JavaScript files.
  5. Click Edit. Choose "Show download dialog" or whatever other option you want Opera to do.

Opera's MIME type list

Opera's file type actions

About MIME types

When you request a file from a web server, the server sends a MIME type header that indicates the type of the file. (When you request a file from an FTP server, there is no MIME type sent, so browsers use the file extension to tell what type the file is.) Typically a browser uses the MIME type to decide how to handle the file. If there's no MIME type available, it uses the file extension.

Opera lets you see all of the MIME types and extensions it knows about and lets you modify how it handles them. Other browsers often show simpler lists.

For the text/ MIME types, if a browser doesn't have a setting for the specific MIME type (like text/css or text/javascript) it will typically just display the text in the browser window because the text/ prefix indicates the file is text-based. Resetting your browser to default settings will probably restore this kind of behavior.

Checking the MIME type

If you change the MIME type action, but the browser's action doesn't change, the web server may be sending a different MIME type then expected. If the browser is displaying the file in the browser window, you can check the MIME type as follows:

  • In Opera, press F4, go to the Info panel, and look at the MIME type.
  • In Firefox, right-click in the window, choose View Page Info, go to the General tab, and look at the Type.

If the MIME type looks like a correct alternative you weren't aware of, you can modify or add it in Opera's file type list.

If the MIME type is wrong or not specific enough (for example, if text/plain is used but text/javascript would be better), consider asking the website administrator to set the server to send a more appropriate MIME type.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.