Closed Bug 297885 Opened 20 years ago Closed 20 years ago

external CSS files are not loaded if the HTML file is opened from the file system (file://...)

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED INVALID

People

(Reporter: u88384, Unassigned)

Details

Attachments

(3 files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4 I have a HTML file with an external stylesheet. When I'm opening the HTML file from the filesystem (e.g. using file:///d:/test/test.htm), mozilla will not load/use the styles from an external CSS file. When the file is loaded via web server (http://...) it works as expected. Internet Explorer displays the file correctly (even with file://...). The external CSS file is included with: <link rel="stylesheet" type="text/css" href="test.css" /> Reproducible: Always Steps to Reproduce: See details. Actual Results: Style definitions from the external CSS are not applied to the HTML file. Expected Results: Load and apply the style definitions from the external CSS.
it's most probably an illegal operation (see message in javascript console) inva ?
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b2) Gecko/20050616 Firefox/1.0+ ID:2005061607 WFM file:///C:/test.html css on C:/test.css
(In reply to comment #3) I have no message in the javascript console. What has CSS loading to do with javascript?
With recent FF versions (maybe even in yours?) errors when loading a CSS stylesheet and errors in the stylesheet itself will be displayed in the JS Console.
BTW: You have any extensions installed? This is also wfm with FF 1.0.4 and Win2k here.
(In reply to comment #6) > BTW: You have any extensions installed? This is also wfm with FF 1.0.4 and Win2k > here. WFM=? I tested it again, with FF 1.0.4 (english) on WinXP (german). I have no extensions installed. No errors in the JavaScript console. No Stylesheet is loaded or applied to the HTML in FF. In IE everything works OK. Please check the screenshot (attachment #2 [details] [diff] [review]).
Attached image Screenshot of the error
Hmm, this is weird I am getting errors here Error: Unexpected end of file while searching for '',' or '{''. Ruleset ignored due to bad selector. Source File: file:///C:/test/test.css Line: 1 Error: Unexpected end of file while searching for 'closing } of invalid rule set'. Source File: file:///C:/test/test.css Line: 1 this is with test.css h1{color:red}
Severity: normal → major
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: blocking-aviary1.1?
Attached file Fixed HTML test page
You have a malformed "test.html" file. I opened it using the html editor from http://nvu.com/ and that program fixed it automatically so that it now works. I have attached the corrected html test page which works in Firefox.
On second look apart from a missing DOC type, the only problem was that you closed the <link> tag when you shouldn't of. It should be: <link rel="stylesheet" ... > Not: <link rel="stylesheet" ... />
my bad i didn't notice this
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
Flags: blocking-aviary1.1?
Also the file doesn't appear to be 8 bit encoded which it should be, but rather some other encoding scheme. Using http://www.pnotepad.org/ I see it's not encoded in either of the four main types. I had to open and save it in windows notepad which converted it to UTF-16 Little Endian encoding before I could change it to 8 bit in pnotepad which fixes it.
I saved the original test page with UNICODE encoding (UTF-16). It seems that this was the reason for the problem. When I save it as ANSI or UTF-8, it is displayed correctly. Adding a DOCTYPE and removing the slash inside the link tag did not help. It only worked after changing the HTML file's encoding. I don't know whether that is a bug in FF (with UTF-16 files) or not, but according to Michaels comment it seems it's not. Thanks for your help.
Additional info: both files (HTML + external CSS) must have the same encoding. Then it also works with UNICODE / UTF-16. This was also reported in bug #161425.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: