What options are there for opening a document fragment in a new tab or window. Which are most browser compatible and which are most user friendly?
var frag = document.createDocumentFragment();
var div = $("<div>").addClass("Printable");
div[0].innerHTML = doc.body.innerHTML;
frag.appendChild(div[0]);
openIt(frag); // How to implement openIt
The fragment contains a reformatted subset of the page that is ready to be printed.
Preferably I would like it to open naturally through some kind <link> or <a> and look like any other user friendly html link, rather then quietly opening up an annoying pop-up through window.open.
You can’t reliably do this without
window.open()and even then you need to create the fragment on thatdocument, rather than the current (as some browsers don’t allow cross-appending elements. It would look something like this:You can test out a demo here.