Frage

Everytime I try to navigate to a JS file on Firefox I get a save-as dialog. I would like to just be able to view the source in the actual browser and not have to download and open the file in another editor.

Is there any way I can force Firefox to view the files?

EDIT here's a snapshot:

snapshot

War es hilfreich?

Lösung

In Firefox, You can use the view-source: psuedo protocol.

Enter into the URL address bar:

view-source:http://server/whatever/your/url/is.js

See also:
How can I convince IE to simply display application/json rather than offer to download it?

Andere Tipps

I would try the excellent Open in Browser add-on, which is worth having as part of your standard Firefox install.

Have you ever been annoyed when you wanted to see a document and the download popup appears which forces you to select an external application to view it?

This extension allows you to open the document directly in browser. You can also change the MIME type of a document being viewed.

enter image description here

This extension is necessary due to a 9 year old bug in Firefox. When given Content-disposition: attachment by the server, Firefox will only offer to open the resource with an external application or to save it to disk. "Open here, now, in this Firefox" should also be an option for MIME-Types it handles, but currently isn't.

I agree with the last comment, from just 8 days ago:

not allowing content types that Firefox can handle (text/plain, image/png, etc) is to be viewed directly is a clear-out bug. Dancing through hoops like saving the file to some random place then opening it manually is a ridiculous workaround.

There are three places that Firefox looks for the MIME type of a .js file. (There is a fourth place for some files, such as .html files.)

The first is in a file in your profile called mimeTypes.rdf; if you have ever clicked on a link to a .js file with an unrecognised MIME type then when you save it Firefox will associate that MIME type with .js files. See Mozilla bug 332690 which describes the equivalent bug for .svg files.

The second possibility is that your registry entry HKEY_CLASSES_ROOT\.js\Content Type may have been set to an incompatible value. If present it should be set to one of the values application/x-javascript, application/javascript or text/javascript.

Only if these locations are not set then Firefox will use its internal default which I believe is application/x-javascript.

There is a nice JSView extension that should help you: https://addons.mozilla.org/en-US/firefox/addon/jsview/

If you view the source of a website in Firefox, you can navigate into the javascript files from there also by just clicking on the link in the src="" property.

(This could potentially be influenced by Firebug that I have installed)

Using the devtools it looks like this Ctrl+Shift+K > Debugger > Sources:

enter image description here

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top