|Import Static HTML5 Footer|
HTML5, js, ajax, footer
Import Static HTML5 Footer
This only works in Firefox
var ajax = new XMLHttpRequest();
ajax.open("GET", "footer.htm", false);
document.body.innerHTML += ajax.responseText;
This works, but it make the code hard to read since the HTML is warped in JS.
No SSI used, just some HTML wrapped in JS.
I have some footer content that needs changing at least monthly.
Maybe I should move on to php from static HTML?
If the content is to be included routinely in every page, not in response to any user activity, then scripting isn't really appropriate anyway.
If you're including static html inside a document that is itself static html, that's an SSI. Sure you can do the same thing in php if you want to, but why bother?
How many different files will this happen to? If the included content only changes every month or so, and you have a high-traffic site, you may want to make cached copies of the finished file and serve those instead.
If you do make it php, you'll have to add a line in your htaccess to parse all html files for php. The alternative is to physically change all your file extensions, and then rewrite from html to php. (Or redirect globally, but that would be silly.) The mechanical details depend on how many files are involved, and what proportion of your total site is involved. There's more than one way to do it.
That was a lot of ifs. Oops.
About a dozen pages.
I didn't think HTML5 & SSI could be mix together?
News to me.
:: detour to investigate ::
Dammit, search engine, a document that talks about PHP 4 and Apache 1.3 cannot possibly be from the past year.
:: further detour to test site to see for myself ::
Far as I can tell, it doesn't care if the dtd says html 4, html 5 (that is, <!doctype html> only) or no dtd at all. Give or take a mysterious added line break which I'll worry about another time. The <!--#include happens regardless.
SSI should work with anything. You may have extra config to do if you want to use SSI with XHTML served as application/xhtml+xml.
@lucy, Google cannot get dates right. It has a lot of page on my site, that have not changed for an year or more, showing dates from the last few months in the SERPS.