How to import html files and open them in new tab when an button is clicked by javascript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to import html files and open them in new tab when an button is clicked by javascript

button tab

13th Oct 2017, 6:33 PM
Aryan Kaushik
Aryan Kaushik - avatar
2 Answers
+ 2
Using jQuery: $.post(url, function (data) { var win=window.open('about:blank'); with(win.document) { open(); write(data); close(); } }); Set this as the onClick event handler for your button. You may have issues with pop-up blockers
14th Oct 2017, 2:38 AM
Shane Overby
Shane Overby - avatar
+ 2
can you give an sample program
14th Oct 2017, 4:51 PM
Aryan Kaushik
Aryan Kaushik - avatar