2009-12-17 29 views
1

我目前正在一個網站上工作。出於調試的原因,我選擇了firefox v3.6b4的視圖源選項。然後我點擊鏈接的JavaScript例如像這樣從源頁面內:第一次見證

<script type="text/javascript" src="./dealer/dialog/jquery-1.3.2.min.js"></script> 

你猜怎麼着,這表明我在下面留言:

<HTML> 
<HEAD> 
<TITLE>404 Not Found</TITLE> 
</HEAD> 
<BODY> 
<H1>Not Found</H1> 
The requested document was not found on this server. 
<P> 
<HR> 
<ADDRESS> 
Web Server at souq4cars.com 
</ADDRESS> 
</BODY> 
</HTML> 

<!-- 
    - Unfortunately, Microsoft has added a clever new 
    - "feature" to Internet Explorer. If the text of 
    - an error's message is "too small", specifically 
    - less than 512 bytes, Internet Explorer returns 
    - its own error message. You can turn that off, 
    - but it's pretty tricky to find switch called 
    - "smart error messages". That means, of course, 
    - that short error messages are censored by default. 
    - IIS always returns error messages that are long 
    - enough to make Internet Explorer happy. The 
    - workaround is pretty simple: pad the error 
    - message with a big comment like this to push it 
    - over the five hundred and twelve bytes minimum. 
    - Of course, that's exactly what you're reading 
    - right now. 
    --> 

這是怎麼回事呢?我無法打開JS文件!

Firefox顯示有關Microsoft和IE的消息!

+2

你能否在這個上加一個更具描述性的標題? – kdgregory 2009-12-17 13:56:04

回答

13

JavaScript文件的路徑很可能不正確。

因此,您(正確)得到您的提供商的標準404錯誤文件。

該錯誤文件包含註釋以使其大於512字節。

也就是說,正如註釋所指出的那樣,因爲Internet Explorer如果小於512字節(source),則不顯示自定義404錯誤頁面。如果它們較小,則會顯示其內置的「找不到的頁面」消息。

改正你的JavaScript文件的路徑,你應該沒問題。

不幸的是,沒有自動化的機制會警告引用但無法加載的Javascript文件(我仍然不明白爲什麼 - 一個能夠拋出Javascript錯誤的瀏覽器也可能會抱怨丟失的文件)。 Firebug的網頁標籤是查找JavaScript文件是否已加載的好方法,我可以推薦非常適合開發。

3

最有可能的是服務器拒絕對URL的請求,而沒有預期的HTTP REFERRER header。這將防止人們直接抓取文件,而不是被預期的文件引用。

嘗試欺騙引用標題並嘗試查看是否獲得相同的響應。

它不是那個或者JavaScript路徑實際上不存在,因此會引發一個404錯誤。

相關問題