Javascript import html is it possible?

前端 未结 6 734
栀梦
栀梦 2020-12-01 13:30

I have some html pages with the same footer. With javascript and only javascript could i import another html page inside it?

6条回答
  •  执笔经年
    2020-12-01 13:44

    You can use ajax to return a whole HTML page. If you wanted to replace the whole page you could replace the body tag and all it's children currently on the page with the body tag returned from the ajax call.

    If you wanted to just replace a section you'd have to write a server-side script to create that section, then use ajax as above but just replace an element rather than the whole page.

提交回复
热议问题