0

I found a great rich text editor A simple but complete rich text editor

and the only problem i have is the printed page of the text editor that pop-up in a new and seperated page but i want it to be in the same page so how can i modify it to reach that ?

function printDoc() {
  if (!validateMode()) { return; }
  var oPrntWin = window.open("","_blank","width=450,height=470,left=400,top=100,menubar=yes,toolbar=no,location=no,scrollbars=yes");
  oPrntWin.document.open();
  oPrntWin.document.write("<!doctype html><html><head><title>Print<\/title><\/head><body onload=\"print();\">" + oDoc.innerHTML + "<\/body><\/html>");
  oPrntWin.document.close();
}

1
  • It shows you all the data in text editor as printable section, how do you want to show in same html ?
    – Narendra
    Nov 9, 2018 at 1:30

1 Answer 1

1

Have a iframe in your HTML like below

 <iframe id="inlineFrameExample" name="inlineFrameExample" title="Inline Frame Example" width="0" height="0">
  </iframe>

and in yur printDoc function, instead of _blank , pass this iframe name inlineFrameExample

var oPrntWin = window.open("", "inlineFrameExample", "width=450,height=470,left=400,top=100,menubar=yes,toolbar=no,location=no,scrollbars=yes");

Explanation

var window = window.open(url, windowname, [windowFeatures]);

windowName

A DOMString specifying the name of the browsing context (window, <iframe> or tab) into which to load the specified resource; if the name doesn't indicate an existing context, a new window is created and is given the name specified by windowName.

1
  • It is a great solution that work like you describe but when I write RTL text the printed page show text LTR you can check this test website link to see how things works and if you want i can provide you with whole script of the editor
    – Falcon_S
    Nov 9, 2018 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.