[英]HTML, CSS, JavaScript modal and many pages
我有一個 HTML 頁面,上面有一個模態彈出窗口。 該頁面具有 Javascript 和 CSS,並且運行良好。 但是,我有 24 頁需要相同的模態函數。 有什么方法可以將模態頁面或代碼從 html 頁面的簡單語法鏈接或引用到模態頁面? 所以我可以有一個單獨的模態頁面,我可以從 24 個頁面中的每個頁面鏈接。 只是為了讓事情簡單。 同樣的方式一個鏈接到一個 css 頁面。
謝謝!
在 html 中沒有辦法在 file1、file2、file3 等中包含來自 filea 的文本。如果沒有太多的工作,在編輯器中復制和粘貼或搜索和替換可能是最快的解決方法。
以下是更復雜的解決方案: 在 HTML 文件中包含另一個 HTML 文件
If you are working on apace server like Xampp. You can create a file called modal.html
Now you can reference the same file in all HTML pages with below code
<!-- Modalstarts -->
<!--#include virtual="modal.html"-->
<!-- Modal ends -->
Setting in XAMPP for this to work
Open httpd.conf file at this path C:\xampp\apache\conf in some editor
Search for AddType text/html .shtml
and replce it by
AddType text/html .html
AddOutputFilter INCLUDES .html
and restart xampp
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.