Windows Tips - Internet Explorer

Can't View Source in IE

Try to View Source In Internet Explorer, but nothing happens?

Synopsis:

When using Internet Explorer, cannot view the source of a web page? Try deleting the Temporary Internet Files.

Quick Solutions:

Compendium
Quick list of view source solutions

Notepad on the Desktop and View Source
Information about having a Notepad folder on the Desktop.

View Source Problem:

Normally the source can be viewed by using the Source command in the View menu, which opens it in Notepad. And also by using the Source command in the popup menu (in Windows, by right-clicking on the page - but not on an image or other object.) In addition to View Source not working, the Edit button is not enabled. This is located on the Standard Buttons toolbar. Normally it would open the page in an external program, such as Notepad.

Solution:

Delete the Temporary Internet Files, otherwise known as the disk cache. The cache includes local copies of web pages and files, so the browser doesn't have to download them again.

In the Tools menu, open Internet Options.... In the General tab, in the Temporary Internet files section, click on Delete Files.

It seems "view source" is affected when the cache gets too large in size. Internet Explorer takes the source from the Temporary Internet Files folder to the folder specified by the TMP environment variable. Refer to Microsoft article Q179829 for more information about this.

Feedback Solutions:

Here are some suggestions based on feedback I've gotten. All entries are in my words, unless otherwise noted. Added is when the entry was included in this page, Updated is when I last modified the entry, From is the name of the person who wrote with the suggestion, and Version is the version of Windows and IE if a specific combination is known.

I've gotten a couple feedback messages from people who've tried the advanced solutions first, and it was the simple solutions that helped them. Because of this, the order is no longer chronological. The simple solutions are now listed first. Refer to the Difficulty, which is marked as Easy or Advanced based on relative simplicity. You may want to try the simple solutions first. Each feedback also has a Category describing if it's a solution or something else like a prevention tip.

(1) Notepad on desktop

If there is a shortcut to Notepad on the desktop, delete or rename it to something other than Notepad.

JR wrote how to reproduce the problem, then solve it:

Open IE, go to any page, view source, works fine.
Now go to Start menu and navigate to "Programs\Accessories", and right-click
on Notepad, drag it to the desktop, selecting "Copy Here" when you let go.
You should now have a shortcut file named "Notepad" on your desktop.
Go back to IE, view source, and nothing happens.
Go back to desktop and delete or rename the Notepad shortcut.
Go back to IE, view source, and it works again.

* JR and Dave wrote two independent mredkj feedbacks about this solution. Yet I have not been able to reproduce it myself in the following combinations: NT/IE 5.5, Win2000/IE 5, and XP/IE 6. There must be other factors that cause a desktop shortcut to affect view source, such as Windows/IE patch versions and registry settings.

Usenet post - This is the earliest reference (2002-12-20 23:46:48 PST) I could find to the Notepad on the desktop solution (via Google Groups archive).

One variation of this issue I can reproduce is when I have a batch file on my desktop named notepad.bat. Trying to view source in IE will run that batch file, and obviously I can't view source. This is not a good thing, since it could be a security vulnerability if a malicious program was executed in the batch file. I was reluctant to mention this, in case it would give hackers/crackers ideas, but I'm sure they already know. As a precaution, don't download suspicious files to your computer, especially files named Notepad to your desktop.

(2) Notepad in Quick Launch toolbar

If there's a shortcut to Notepad in your Quick Launch toolbar, rename it to something other than Notepad.

Instructions to rename a shortcut in the Quick Launch.

Alex said:

I had an issue where I could view the source of some pages but not others. I had a "Notepad" shortcut in my XP taskbar, and when I renamed this to "Text viewer" (as recommended for shortcuts on the desktop) View Source worked fine again for all pages.

(3) Even after deleting the Temporary Internet Files, hidden files may still remain

According the Microsoft Knowledge Base article 301057, Temporary Internet Files may use more space than specified. This may be caused by incomplete downloads or for other reasons. Even after deleting the files (Tools > Internet Options... > Delete Files...) they will remain and are not visible in Windows Explorer. Although not mentioned in the article, if the remaining file or files take up too much space, it could cause the same view source problem mentioned in the main solution above.

Thanks to Sheila who discovered Microsoft's KB article, and explained how following their workaround helped restore View Source.

Even though my view source was working already, I went through the steps myself, so I could better explain it here. "Temporary Internet Files" and "TIF" are used interchangeably.
[OS: Windows 2000 Professional SP4; browser: IE6.0 SP1]
[OS: Windows XP Professional SP2; browser: IE6.0 SP2]

  1. Let's say your Temporary Internet Files is set to
    C:\Documents and Settings\YourUser\Local Settings\Temporary Internet Files
    I'm going to call this the original TIF.
  2. In Windows Explorer, create a new folder anywhere. I'm going to call this the temporary fix folder.
  3. In Internet Explorer, go to the Tools menu, then Internet Options.... In the General tab, in the Temporary Internet files section, click Settings.... In the Settings dialog, in the Temporary Internet files folder section, click Move Folder... Find the temporary fix folder and click OK.
  4. Windows should prompt you to log out. When you log back in, notice how Windows created a new Temporary Internet Files in the temporary fix folder. View source should work at this point, but keep going to switch back to the original TIF.
  5. The original TIF should have been removed by Windows, and the contents transferred over to the TIF in the temporary fix folder. If the original TIF is not gone, then delete it.
  6. Follow the instructions in step C, but this time select the parent folder of the original TIF location.
    e.g. C:\Documents and Settings\YourUser\Local Settings\
    Once you've logged back in, the TIF in temporary fix folder should be gone, and Windows should have created a new Temporary Internet Files in the original TIF location.

Sheila stopped at step D since view source was working at that point.
Sheila: [OS: Windows XP; browser: IE6]

I later received feedback from Gary, who was not able to delete the original TIF (refer to step E of my instructions). Gary recommends that if you can't delete the original TIF, then in Windows Explorer delete its contents (including the cookies), then switch back the TIF to
C:\Documents and Settings\YourUser\Local Settings\ (as described in step F).
Gary: [OS: Windows XP Home; browser: IE6]

An additional note from Sheila:

Another symptom of this problem also seems to be that when you copy images 'save picture as' .. they all save as .bmp ... this was also resolved and I can now save .jpg and .gif

(4) Clean up Windows TMP directory

If you've already tried deleting the Temporary Internet Files as described at the top of this page, then another possibility is the Windows temporary folder may need cleaning up. One way of deleting files from the temp directory is by using Windows Disk Cleanup.

  • One way of opening Disk Cleanup is in: Start > Programs > Accessories > System Tools > Disk Cleanup
  • Select the drive you want to clean up - e.g. (C:) - and click OK
    • It calculates how much space it can free up
  • In the Disk Cleanup tab, check "Temporary files" and uncheck the others
  • Click OK and then confirm Yes

Try to view source in IE again. If it didn't restore view source, then try manually deleting the files/folders in TMP. It will usually be in
C:\Documents and Settings\[your user]\Local Settings\Temp

Arnaud wrote:

To fix it, I went to start menu, clicked on "run...", typed "%TMP%" to open my temp directory in explorer. Then I deleted all files that were not locked.

(5) Set the HTML editor to Notepad instead of Microsoft FrontPage

While in Internet Explorer, go to the Tools menu, then Internet Options. In the Programs tab, change the HTML editor drop down to Notepad. You can also get to Internet Options from the Control Panel.

Lars wrote:

[If] your default HTML editor is referring to any software that is not installed on your computer you will also end up with the "can't View Source in IE" problem.

(6) Uncheck Auto-Select for Encoding

Internet Explorer can be set to automatically detect the charset encoding, but this may cause View Source to stop working for certain pages. A workaround is to turn off Auto-Select.

Ralph wrote:

This occurred on Win2k Pro SP3 and IE 6 SP1. You are correct that Auto-Select can be set independently of an encoding. The issue occurs if Auto-Select is selected, irregardless of the selected encoding. The problem is consistently reproducible when checking the Auto-Select feature. It does occur on specific web pages that are English, some of which are internal and definitely all English. It occurs consistently on these web pages. It's probably about 40% of web pages that it occurs on though. The issue did not start until after a Windows Update though, so I'm fairly confident that it was an update that triggered the issue. Which update I could not say though.

While in Internet Explorer, go to the View menu, then Encoding and uncheck Auto-Select.

Update - 2005-08-08
If Auto-Select is already turned off, another suggestion is to just go into View > Encoding and reselect your current encoding.

Ori wrote:

When ever I can't view the source, I just choose view encoding and choose the same encoding that is used now.

(7) SSL / Do not save encrypted pages to disk

If View Source is turned off for https URLs, it may be because of a security setting. Look in Tools > Internet Options > Advanced tab > Security section, and look for the option Do not save encrypted pages to disk. When checked off, this option will intentionally disable View Source.

And to confuse the issue, according to Microsoft KB article 811102 "Do Not Save Encrypted Pages to Disk" was not working properly in Internet Explorer 6 SP1, causing it to leave View Source enabled even when the option was checked. This problem was corrected in a hotfix. From the KB article:

After you install this hotfix, if you load SSL-secured content while you have selected the Do not save encrypted page to disk option, the Source menu is not available.

(8) Prevent cache from getting too large

Prevent the problem by adjusting the amount of disk space the cache uses. To change the amount of disk space, go to the Tools menu and open Internet Options.... In the General tab's Temporary Internet files section, open Settings.... Here you can use the slider or change the amount of disk space by typing into the text box. "ThanksAlot" set the cache to use up to 50 MB of disk space.

(9) Set browser to clear cache on close

Prevent the problem by clearing the cache when the browser is closed. To activate this setting, go to the Tools menu and open Internet Options.... In the Advanced tab, go to the Security section. Check on or off the option to "Empty Temporary Internet Files folder when browser is closed".

(10) Missing registry setting

Warning: Please use standard precautions when editing the Windows Registry. For more information about the registry, refer to WinGuides.com

The source of Dean's suggestion is Microsoft's Online Assisted Support, where one of the MS support technicians diagnosed the problem by asking questions in a series of emails. Last time I checked, this information was still not available as a View Source solution in Microsoft's Knowledge Base, but refer below to "(12) Additional documentation for useful registry settings".

Microsoft's Online Assisted Support and Knowledge Base are available at support.microsoft.com.

Dean wrote:

1. Close any instances of IE.

2. Create this registry key if it does not already exist (chances are it does not exist):
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source Editor\Editor Name]

3. Modify the Default value of the "Editor Name" to the path of the program you want to use to view source code. For example, "C:\Program Files\Accessories\wordpad.exe" or "C:\Windows\notepad.exe"

Note: If the path contains blank spaces, please do not forget to add the quotation marks. Then when you click View>Source in Internet Explorer, the program you specified will open.

(11) Create another user account in Windows

This is another one that I haven't tested. Caveat emptor.

Jim wrote:

Setup another user account with admin privileges and then copy over the desktop and favorites folders. That should work, but if it doesn't delete the new user account and most likely your original account will now work.

(12) Additional documentation for useful registry settings

Chris wrote with a link to an MSDN page that would be helpful to those who need to change registry settings for View Source, HTML editors, etc.

Internet Explorer Client Registry Layout

 

Microsoft Knowledge Base Solutions:

After my View Source stopped working, I installed the Internet Explorer 5.01 Service Pack. That did not work. So, I looked at Microsoft's Knowledge Base to find some help. Here are some similar problems/solutions. For each link, I summarized their solution.

Update (November 09, 2002)
It was January 13, 2001 when I first put up this page, and Microsoft's Knowledge Base didn't have a "Delete Temporary Internet files" solution at the time. Either that or I couldn't find it, because I found an article now. Refer to Q306907 below. The article says it was last reviewed on Monday, October 07, 2002, but not when it was created.

Conclusion

To help prevent the problem, one should set the cache to use a small amount of disk space relative to the size of the hard disk. For the other cache settings, it is up to the individual. If clearing the cache every time the browser is closed seems drastic, then one could manually clear it occasionally. The following links offer a couple perspectives.

"Working Efficiently" (Microsoft) - The advice from Microsoft is to increase the cache size to improve efficiency.

"Keep it Clean" (Commerce Developers) - While Microsoft says to increase cache size, Commerce Developers suggests not letting Temporary Internet files get too large or outdated. We agree with this, because although pages will load faster when cached, there is a limit at which the cache will become inefficient.

Operating System and Browser

In 2001, when I first had the view source problem, I was using Windows 2000 for my OS and Internet Explorer 5.0 for my browser.

About this page: