how can I insert an html file into another html file using javascript or jquery?

how can I insert an html file into another html file using javascript or jquery?
LVL 1
BRMarketingAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shaun VermaakTechnical Specialist/DeveloperCommented:
As in read it and insert it into a DIV or as in an IFRAME?
0
BRMarketingAuthor Commented:
not iframe,
I have a menu, navigation bar menu..
I want to save the menu as an html page and insert it in every page that I want to use this menu.
how can I do that using jquery or javascript?
0
Chinmay PatelChief Technical NinjaCommented:
Hi BR,

The technique you want to use is called JavaScript templating. You can do it on your own or you can use an existing framework such as: https://github.com/blueimp/JavaScript-Templates
And then in your code define the template as shown here: https://blueimp.github.io/JavaScript-Templates/

Steps to do this for your own Menu system would be
1. Include the template engine : <script src="js/tmpl.min.js"></script>
2. Define your menu content as shown in the sample/s above.
3. Have fun :)

If you don't like the template engine I have mentioned, you can always find some others here: https://www.sitepoint.com/overview-javascript-templating-engines/

Regards,
Chinmay.
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BRMarketingAuthor Commented:
Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.