开发者

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 c开发者_如何转开发ase Javascript is disabled.


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>
  ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜