views:

115

answers:

1

We have an offline set of HTML pages we're working with using HTML5 document type. We want to include our sub-navigation via a <script src="____"> but for some reason it's not including. Is there some other method of including the file without needing server-side assistance somewhere?

Because of how we're delivering these files to the client we must work offline, but it would seriously suck to have to update 100 files due to a simple sub-nav change that could be globally included via Javascript somehow.

+2  A: 

You could put an empty div

<div id="navigation"></div>

And then "load" that with jQuery

$("#navigation").load("path/to/nav/file.html");
Josh K
Thanks. I'll try that. I found this page which works in Firefox (perfectly) but IE requires an ActiveX prompt (due to external content) where Chrome doesn't work at all. http://www.javascriptkit.com/dhtmltutors/ajaxincludes.shtml
Will Ashworth
@Will: Sure, look at the jQuery source and figure out how the `load()` function works. You can probably slice everything you need out of there. Make sure to get the unminified source.
Josh K
Actually, what you posted works everywhere except for Google Chrome browser. Firefox and IE are good to go. Any ideas why Chrome sucks in this one instance?
Will Ashworth
@Will Ashworth: Chrome seems to have some issues when working with files on localhost (on Ubuntu this is applicable to both `/var/www/index.html` *and* `localhost/index.html`). It *might* behave differently if the file's accessed on the internet.
David Thomas
@Will: What @David said. I would recommend finding an absolute path for Chrome.
Josh K