將外部腳本載入到頁面中,而無需執行任何inline 腳本。然而,以下用法是不正確的:

在此範例中,inline 腳本將被忽略,因為 src 屬性存在。要執行 inline 腳本,必須省略 src 屬性:

","image":"http://www.luping.net/uploads/20241104/173069029667283cf8c7d54.jpg","datePublished":"2024-11-04T12:45:54+08:00","dateModified":"2024-11-04T12:45:54+08:00","author":{"@type":"Person","name":"luping.net","url":"https://www.luping.net/articlelist/0_1.html"}}
」工欲善其事,必先利其器。「—孔子《論語.錄靈公》

您可以在標籤中同時包含內聯腳本和 SRC 屬性嗎?

發佈於2024-11-04
瀏覽:266

Can you include both inline scripts and an SRC attribute in a  tag?

JavaScript: Inline Script with SRC Attribute

JavaScript inline scripts are commonly included using the

According to the HTML 4.01 Specification, the behavior of a

如果src 屬性未設置,用戶代理必須將元素的內容解釋為腳本。如果 src 有 URI 值,使用者代理程式必須忽略元素的內容並透過 URI 檢索腳本。

這意味著

將外部腳本載入到頁面中,而無需執行任何inline 腳本。然而,以下用法是不正確的:

在此範例中,inline 腳本將被忽略,因為 src 屬性存在。要執行 inline 腳本,必須省略 src 屬性:

最新教學 更多>

免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。

Copyright© 2022 湘ICP备2022001581号-3