Falcon_S
Falcon_S

Reputation: 502

Print in the same not in a pop-up new seperated page

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();
}

Upvotes: 0

Views: 32

Answers (1)

Narendra
Narendra

Reputation: 4574

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.

Upvotes: 1

Related Questions