Zade
Zade

Reputation: 692

Bring in HTML from a separate file

I have a site that changes the content of the page when you hover over the navigation links: http://www.dolphinbeams.com/

Basically all the DIVs are on one page and I use jQuery to display them as necessary. However, to ensure compatibility with non-Javascript browsers, I have also created separate html files for each of the pages.

Each page has the same body content, with a different body id and title. I'm wondering if there's an easy way I can have the body content in a separate file (for editing), then bring it in to all the pages. What the simplest way to achieve this?

Keep in mind I don't know much about PHP, though I'd consider it if it's the easiest way. Also I'd like to ensure the content is still visible in case Javascript is disabled.

Upvotes: 1

Views: 126

Answers (1)

Alienz
Alienz

Reputation: 118

rename your index from html to .php.

add this line where you want your page to display:

    <? include("contentFile.html"); ?>

No other php knowledge required.

For example you have the divs that appear and disappear. It might look like this:

   <div id="content1"> 
           <? include("content1.html"); ?>
   </div>

   <div id="content2"> 
           <? include("content2.html"); ?>
   </div>
  ...

Upvotes: 2

Related Questions