2

I have an HTML page that has a modal popup window on it. The page has Javascript and CSS and works fine. However, I have 24 pages that I need the same modal function on. Is there any way to link or reference the modal page or code from a simple syntax from the html page to a modal page? So I can have a separate modal only page that I can link from each of the 24 pages. Just to keep things simple. SAme way one links to a css page.

Thanks!

Scott Marcus
  • 57,085
  • 6
  • 34
  • 54
Jon
  • 21
  • 1

2 Answers2

0

There is no way within html to include text from filea in file1,file2,file3 etc. If it is not too much work copy and paste or search and replace in an editor might the quickest fix.

Here are more complex solutions: Include another HTML file in a HTML file

JohnC
  • 1,010
  • 11
  • 25
0
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
KKGupta
  • 246
  • 1
  • 2
  • 6
  • Not working in Xampp, but that is the idea I am looking for, being able to reference the file from the webpages. Something like a simple edit to this line of code that I have on the page now that does the work. Open Modal – Jon Jan 02 '20 at 14:13