How to get IE to open JavaScript as text
Try adding an entry for JS files to the MIME type database in the registry via the following .REG file (courtesy Cheeso's answer here):
Windows Registry Editor Version 5.00
;
; Tell IE to open JS documents in the browser.
; 25336920-03F9-11cf-8FD0-00AA00686F13 is the CLSID for the "Browse in place".
;
[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/x-javascript]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Encoding"=hex:08,00,00,00
[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/javascript]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Encoding"=hex:08,00,00,00
Related videos on Youtube
Comments
-
Pete over 1 year
I am running IE 9. Up until last week sometime, if I would put the URL of a JavaScript file in the address bar, it would show the JavaScript as text in the browser window. Now when I do that, it wants to download the JavaScript file.
How can I revert it to the previous handling?
This is annoying since I'm developing a web application and if I can get it to display the
.js
files as text in the browser, then I can refresh it to force the cache to update.Update: I've tested on several co-workers machines. For some, browsing to .js files renders them in the browser (IE 9 in all cases). In others, it asks for a download. File associations don't seem to have any effect. One co-worker we tested with IE and Chrome. IE wanted to download it, but Chrome rendered it as text. This makes me think it's an IE issue and not an OS issue.
-
Julian Knight over 11 yearsPerhaps if you shared the URL we could give a better answer?
-
Pete over 11 yearsThe Javascript file is on my machine. I do web development. Here's the URL: localhost/georgescript.js I don't think that's going to help you solve my problem, though.
-
Julian Knight over 11 yearsActually it does help slightly - it does tell me you are running a local web server. Doesn't look like it works in IE10 either. In fact, you end up with about 5 or 6 clicks before you get anywhere. Though that was from a random web page on the web. It's not an answer but I'd choose a more developer friendly browser!! ;)
-
Julian Knight over 11 yearsFor other people's benefit (I'm sure you understand), it DOES matter since IE applies very different security rules to locally accessed (using file:///) to server accessed (http://) files. Personally, for local development, I just keep a copy of Sublime Text 2 open with the appropriate files (yes, I know that doesn't update the cache, I just add a version to the URL or do a ctrl-f5).
-
Karan over 11 yearsSince it works on some machines, carefully compare all the browser security settings on those PCs with the settings on the PCs where it doesn't work. You can also see whether the .REG file given here helps (after suitable editing, of course).
-
Pete over 11 years@Karan, that link gave me the answer. I simply added a key in the MIME content type database for application/x-javascript (there wasn't one, not sure if there should be or not) and set the CLSID string to "{25336920-03F9-11cf-8FD0-00AA00686F13}" which says it's an HTML document, restarted my browser, and it worked (Javascript still appears to execute fine on web pages as well). If you'll post that as an answer, I'll check it off. Thanks!
-
Karan over 11 years@Pete: Added an answer as requested; glad it worked out. :) BTW, did you check if the key already existed on those PCs where it worked? If not, I wonder what setting did the trick there?
-
Pete over 11 years@Karan, yes, I did check and they don't have it. Unfortunately I'm in a bit of a crunch right now for a demo tomorrow, but I may explore this more. I suspect there's something in IE settings that does the equivalent.
-
-
Pete over 11 yearsWell, in addition to being able to refresh, it's simply handy for me to see what version of the .JS it's using. Yes, I can F12 it, but I can also F12 to refresh the .js. What I want is to fix it back to the way it was because that was the most effecient way for me to work.
-
Pete over 11 yearsUnfortunately we develop for IE only as it's the company's choice of browser (certainly not mine). And this is not an update/version issue (see my update. We compared version numbers and revisions).
-
Steen Schütt over 11 yearsYes, exactly. I too, was trying to open a .js file in IE 9 resulting in a downloaded javascript. This is an interesting issue, but I'm out of ideas then.
-
Jez over 9 yearsTried this, didn't work for me (though I'm using IE11). It prompts me to Run or Download the .js file. IE is still an unbelievable pile of crap.
-
Trung Nguyen over 8 yearsThis works for me using IE11. Have just edited the answer to include another javascript type. If IE does report any other different file/type, just add as required.