Търсене в помощните статии

Избягвайте измамите при поддръжката. Никога няма да ви помолим да се обадите или изпратите SMS на телефонен номер или да споделите лична информация. Моля, докладвайте подозрителна активност на "Докладване за злоупотреба".

Научете повече

Opening html code rather than web page

  • 13 отговора
  • 10 имат този проблем
  • 1 изглед
  • Последен отговор от serky100

more options

I am using Firefox 8. I have a simple html file called test.html stored locally.

When I double click on the file it open in Firefox as html code rather than the web page. What am I doing wrong?

I am using Firefox 8. I have a simple html file called test.html stored locally. When I double click on the file it open in Firefox as html code rather than the web page. What am I doing wrong?

Избрано решение

I have resolved the issue. The file was working correctly. I made the mistake of coding html in a text file and then saving the file as html. This resulted in the html tags being coded a second time with html. Hence being able to view html tags in the web page.

Прочетете този отговор в контекста 👍 0

Всички отговори (13)

more options

Are you loading that file via a local server via the http:// protocol or as a file via the file:///protocol?

If it is via a server then make sure that the file is send as text/html

more options

I don't know which protocol is being used. How do I find out?

I am not using a server - just my own Mac.

more options

Which URL so you see in the location (address) bar if you open the file? If it starts with http:// then it is opened as a web page and not as a file.

Also make sure that the file doesn't have a .txt file extension i.e. test.html.txt that is possibly added if you save a file in a text editor.

more options

Hello

after replying to you, I looked further than my nose and noticed that the URL starts with file:/// The file suffix is definitely html (yes it was edited in text edit but I did a 'save as' html).

What determines what protocol is being used? Is there a setting that I need to change? I thought that the Mac would recognise that it's a html file (from the file suffix) and load as a web page into browser.

I have not activated the web server on my mac. Is this the problem?

more options

Firefox should automatically display .html files rendered and not as text files even if loaded with the file protocol.

Can you post the first few lines of that file?

more options

It's very simple as I'm just starting to learn. I copied it from a site to test the html.

<html>

<head>
</head>

<body>

<h2>My first webpage!</h2>

</body>
</html>

Променено на от cor-el

more options

I just noticed that my reply above converted the html to web. Useful!

I copied it again and removed the first and end bracket for the html tag.

html>

<head> </head>

<body>

My first webpage!

</body>

more options

So, there is nothing wrong with the file.

What do you see in Tools > Page Info > General ?

more options

I have added a screenshot below to show Tools > Page Info > General

Does this explain the problem?

more options

That still doesn't show that there is a problem: opened as text/html and rendered in Standards compliant mode.


Start Firefox in Diagnose Firefox issues using Troubleshoot Mode to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).

more options

I tried this (Firefox looks weird as I have customised it to some degree!)

It didn't fix the problem. I double clicked on test.html and it open showing the html tags and the file:/// protocol.

I am currently considering changing career to website design/development but am wondering if this is feasible when I can't even get a 6 line html file to work!!

more options

I also tried it in Safari 5.1.1. The same problem occurs. Is this suggesting a Mac problem rather than Firefox?

more options

Избрано решение

I have resolved the issue. The file was working correctly. I made the mistake of coding html in a text file and then saving the file as html. This resulted in the html tags being coded a second time with html. Hence being able to view html tags in the web page.