jquery - Duplicate an HTML file (and its content) with a different name in Javascript -


i have html file javascript , css applied on. duplicate file, make file1.html, file2.html, file3.html,...
all of using javascript, jquery or ! idea create different page (from kind of template) printed afterwards different data in (from xml file). hope possible ! feel free ask more precision if want !

thank advance

note: not want copy content entire file.

edit: know should use server-side language, don't have option ):

there couple ways go implementing similar describing. implementation should use depend on goals are.

first of all, recommend sort of template system such vuejs, angularjs or react. however, given don't have option of using server side language, suspect won't have option implement 1 of these systems.

my next suggestion, build own 'templating system'. simple implementation may suit needs mirroring following:

in primary file (root file) want route or copy other files through to, use js include correct html files. example, have js conditionally load file depending on circumstances putting following after conditional statement:

note while doing optimize server's data usage (as serve required files , not time), increase loading times. site need wait additional http request come through , whatever requested content load & render on client. while sounds slow has potential of not being bad if don't have many discrete requests, , none of code unusually large or computationally expensive.

if using vanilla js, following snippet illustrate above: in script comes loaded routing file:

  function read(text) {       var xhr=new xmlhttprequest;       xhr.open('get',text);       xhr.onload=show;       xhr.send();   }    function show() {       var text = this.response;       document.body.innerhtml = text;//you can replace document.body whatever element want wrap imported html    }    read(path/to/file/on/server); 

note couple of things above code. if testing on computer (ie opening html file on browser, path file://__) without local server, sort of cross origin request error when trying make xml request. bypass error, either test code on actual server (not ideal pushing code, know) or, preferably, set local testing server. if want explore, not difficult do, let me know , i'd happy walk through process.

alternately, implement above loading system jquery , .load() function. http://api.jquery.com/load/

if none of above solutions work you, let me know more need, , i'll happy give more useful/ relevant answer!


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -