admin管理员组文章数量:1290136
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.
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.
Share Improve this question edited Sep 10, 2010 at 19:41 ndim 37.9k12 gold badges49 silver badges58 bronze badges asked Sep 10, 2010 at 19:18 Will AshworthWill Ashworth 1,0883 gold badges14 silver badges29 bronze badges 1- As a further example, let's imagine we're totally offline with our HTML (no server) as if we're putting these onto a CD-Rom or DVD. I'm guessing there may be some clever trick with Ajax that I'm not thinking of just yet. – Will Ashworth Commented Sep 10, 2010 at 19:22
2 Answers
Reset to default 10You could put an empty div
<div id="navigation"></div>
And then "load" that with jQuery
$("#navigation").load("path/to/nav/file.html");
External HTML code can be included via .js file. Here is an example:
<!DOCTYPE html>
<html>
<head>
<title>Main Page</title>
<script type="text/javascript" src="include_html.js"></script>
</head>
<body>
<script type="text/javascript">
paragraph();
</script>
</body>
</html>
Contents of include_html.js
function paragraph()
{
document.write("<p> This is an HTML paragraph </p>");
}
本文标签: javascriptOffline HTML5 html pagesneed to include file into another fileStack Overflow
版权声明:本文标题:javascript - Offline HTML5 .html pages - need to include file into another file - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741494032a2381752.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论