Ok, here is what I want to do:
include a header and a footer from external html file to another html file.
I know, there are lots of available snippets here. But...
...problems: I can't modify those external html and they contains a full <head> with meta, links and all.
here are code-snippets i have found (from @amir-saniyan - github ):
(function ($) {
$.include = function (url) {
$.ajax({
url: url,
async: false,
success: function (result) {
document.write(result);
}
});
};
}(jQuery));
$.include("_header.html");
$.include("_footer.html");
and
$crop_start = (result.indexOf('<body>') !== -1) ? result.indexOf('<body>') + 7 : 0;
$crop_end = (result.indexOf('</body>') !== -1) ? result.indexOf('</body>') : result.length;
result = result.substring($crop_start, $crop_end);
How to merge the two html-code structures for having the expected result:
- import that external
htmlinto another one, but without head ( only thehtml-code between the<body></body>tags )