Apply script on another function










0














I have a text editor and i want when you print print to see results with no date,link or title thats why i use this script to have 0 margin and portrait






var cssPagedMedia = (function () 
var style = document.createElement('style');
document.head.appendChild(style);
return function (rule)
style.innerHTML = rule;
;
());

cssPagedMedia.margin = function (margin)
cssPagedMedia('@page margin: ' + margin + '');
;

cssPagedMedia.margin('0');

cssPagedMedia.size = function (size)
cssPagedMedia('@page size: ' + size + '');
;

var cssPagedMedia = (function ()
var style = document.createElement('style');
document.head.appendChild(style);
return function (rule)
style.innerHTML = rule;
;
());

cssPagedMedia.size = function (size)
cssPagedMedia('@page size: ' + size + '');
;

cssPagedMedia.size('portrait');





But this script work only on the main page if you tried to print it but not text in text-editor and you can see example



and i want to apply previous script on the text editor's javascript and this the whole javascript of the text-editor






var oDoc, sDefTxt;

function initDoc()
oDoc = document.getElementById("textBox");
sDefTxt = oDoc.innerHTML;
if (document.compForm.switchMode.checked) setDocMode(true);


function formatDoc(sCmd, sValue)
if (validateMode()) document.execCommand(sCmd, false, sValue); oDoc.focus();


function validateMode()
if (!document.compForm.switchMode.checked) return true ;
alert("Uncheck "Show HTML".");
oDoc.focus();
return false;


function setDocMode(bToSource)
var oContent;
if (bToSource)
oContent = document.createTextNode(oDoc.innerHTML);
oDoc.innerHTML = "";
var oPre = document.createElement("pre");
oDoc.contentEditable = false;
oPre.id = "sourceText";
oPre.contentEditable = true;
oPre.appendChild(oContent);
oDoc.appendChild(oPre);
document.execCommand("defaultParagraphSeparator", false, "div");
else
if (document.all)
oDoc.innerHTML = oDoc.innerText;
else
oContent = document.createRange();
oContent.selectNodeContents(oDoc.firstChild);
oDoc.innerHTML = oContent.toString();

oDoc.contentEditable = true;

oDoc.focus();


function printDoc()
if (!validateMode()) return;
var oPrntWin = window.open("","inlineFrameExample","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></title></head><body onload="print();">"+ "<div dir='rtl'>" + oDoc.innerHTML + "</body></html>");
oPrntWin.document.close();

/*page margin*/
var cssPagedMedia = (function ()
var style = document.createElement('style');
document.head.appendChild(style);
return function (rule)
style.innerHTML = rule;
;
());

cssPagedMedia.margin = function (margin)
cssPagedMedia('@page margin: ' + margin + '');
;

cssPagedMedia.margin('0');
/*page size*/
cssPagedMedia.size = function (size)
cssPagedMedia('@page size: ' + size + '');
;

var cssPagedMedia = (function ()
var style = document.createElement('style');
document.head.appendChild(style);
return function (rule)
style.innerHTML = rule;
;
());

cssPagedMedia.size = function (size)
cssPagedMedia('@page size: ' + size + '');
;

cssPagedMedia.size('portrait');





So how can i make printing for text-editor show 0 margin and protrait no matter what are the default printing settings in your browser ?










share|improve this question


























    0














    I have a text editor and i want when you print print to see results with no date,link or title thats why i use this script to have 0 margin and portrait






    var cssPagedMedia = (function () 
    var style = document.createElement('style');
    document.head.appendChild(style);
    return function (rule)
    style.innerHTML = rule;
    ;
    ());

    cssPagedMedia.margin = function (margin)
    cssPagedMedia('@page margin: ' + margin + '');
    ;

    cssPagedMedia.margin('0');

    cssPagedMedia.size = function (size)
    cssPagedMedia('@page size: ' + size + '');
    ;

    var cssPagedMedia = (function ()
    var style = document.createElement('style');
    document.head.appendChild(style);
    return function (rule)
    style.innerHTML = rule;
    ;
    ());

    cssPagedMedia.size = function (size)
    cssPagedMedia('@page size: ' + size + '');
    ;

    cssPagedMedia.size('portrait');





    But this script work only on the main page if you tried to print it but not text in text-editor and you can see example



    and i want to apply previous script on the text editor's javascript and this the whole javascript of the text-editor






    var oDoc, sDefTxt;

    function initDoc()
    oDoc = document.getElementById("textBox");
    sDefTxt = oDoc.innerHTML;
    if (document.compForm.switchMode.checked) setDocMode(true);


    function formatDoc(sCmd, sValue)
    if (validateMode()) document.execCommand(sCmd, false, sValue); oDoc.focus();


    function validateMode()
    if (!document.compForm.switchMode.checked) return true ;
    alert("Uncheck "Show HTML".");
    oDoc.focus();
    return false;


    function setDocMode(bToSource)
    var oContent;
    if (bToSource)
    oContent = document.createTextNode(oDoc.innerHTML);
    oDoc.innerHTML = "";
    var oPre = document.createElement("pre");
    oDoc.contentEditable = false;
    oPre.id = "sourceText";
    oPre.contentEditable = true;
    oPre.appendChild(oContent);
    oDoc.appendChild(oPre);
    document.execCommand("defaultParagraphSeparator", false, "div");
    else
    if (document.all)
    oDoc.innerHTML = oDoc.innerText;
    else
    oContent = document.createRange();
    oContent.selectNodeContents(oDoc.firstChild);
    oDoc.innerHTML = oContent.toString();

    oDoc.contentEditable = true;

    oDoc.focus();


    function printDoc()
    if (!validateMode()) return;
    var oPrntWin = window.open("","inlineFrameExample","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></title></head><body onload="print();">"+ "<div dir='rtl'>" + oDoc.innerHTML + "</body></html>");
    oPrntWin.document.close();

    /*page margin*/
    var cssPagedMedia = (function ()
    var style = document.createElement('style');
    document.head.appendChild(style);
    return function (rule)
    style.innerHTML = rule;
    ;
    ());

    cssPagedMedia.margin = function (margin)
    cssPagedMedia('@page margin: ' + margin + '');
    ;

    cssPagedMedia.margin('0');
    /*page size*/
    cssPagedMedia.size = function (size)
    cssPagedMedia('@page size: ' + size + '');
    ;

    var cssPagedMedia = (function ()
    var style = document.createElement('style');
    document.head.appendChild(style);
    return function (rule)
    style.innerHTML = rule;
    ;
    ());

    cssPagedMedia.size = function (size)
    cssPagedMedia('@page size: ' + size + '');
    ;

    cssPagedMedia.size('portrait');





    So how can i make printing for text-editor show 0 margin and protrait no matter what are the default printing settings in your browser ?










    share|improve this question
























      0












      0








      0


      1





      I have a text editor and i want when you print print to see results with no date,link or title thats why i use this script to have 0 margin and portrait






      var cssPagedMedia = (function () 
      var style = document.createElement('style');
      document.head.appendChild(style);
      return function (rule)
      style.innerHTML = rule;
      ;
      ());

      cssPagedMedia.margin = function (margin)
      cssPagedMedia('@page margin: ' + margin + '');
      ;

      cssPagedMedia.margin('0');

      cssPagedMedia.size = function (size)
      cssPagedMedia('@page size: ' + size + '');
      ;

      var cssPagedMedia = (function ()
      var style = document.createElement('style');
      document.head.appendChild(style);
      return function (rule)
      style.innerHTML = rule;
      ;
      ());

      cssPagedMedia.size = function (size)
      cssPagedMedia('@page size: ' + size + '');
      ;

      cssPagedMedia.size('portrait');





      But this script work only on the main page if you tried to print it but not text in text-editor and you can see example



      and i want to apply previous script on the text editor's javascript and this the whole javascript of the text-editor






      var oDoc, sDefTxt;

      function initDoc()
      oDoc = document.getElementById("textBox");
      sDefTxt = oDoc.innerHTML;
      if (document.compForm.switchMode.checked) setDocMode(true);


      function formatDoc(sCmd, sValue)
      if (validateMode()) document.execCommand(sCmd, false, sValue); oDoc.focus();


      function validateMode()
      if (!document.compForm.switchMode.checked) return true ;
      alert("Uncheck "Show HTML".");
      oDoc.focus();
      return false;


      function setDocMode(bToSource)
      var oContent;
      if (bToSource)
      oContent = document.createTextNode(oDoc.innerHTML);
      oDoc.innerHTML = "";
      var oPre = document.createElement("pre");
      oDoc.contentEditable = false;
      oPre.id = "sourceText";
      oPre.contentEditable = true;
      oPre.appendChild(oContent);
      oDoc.appendChild(oPre);
      document.execCommand("defaultParagraphSeparator", false, "div");
      else
      if (document.all)
      oDoc.innerHTML = oDoc.innerText;
      else
      oContent = document.createRange();
      oContent.selectNodeContents(oDoc.firstChild);
      oDoc.innerHTML = oContent.toString();

      oDoc.contentEditable = true;

      oDoc.focus();


      function printDoc()
      if (!validateMode()) return;
      var oPrntWin = window.open("","inlineFrameExample","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></title></head><body onload="print();">"+ "<div dir='rtl'>" + oDoc.innerHTML + "</body></html>");
      oPrntWin.document.close();

      /*page margin*/
      var cssPagedMedia = (function ()
      var style = document.createElement('style');
      document.head.appendChild(style);
      return function (rule)
      style.innerHTML = rule;
      ;
      ());

      cssPagedMedia.margin = function (margin)
      cssPagedMedia('@page margin: ' + margin + '');
      ;

      cssPagedMedia.margin('0');
      /*page size*/
      cssPagedMedia.size = function (size)
      cssPagedMedia('@page size: ' + size + '');
      ;

      var cssPagedMedia = (function ()
      var style = document.createElement('style');
      document.head.appendChild(style);
      return function (rule)
      style.innerHTML = rule;
      ;
      ());

      cssPagedMedia.size = function (size)
      cssPagedMedia('@page size: ' + size + '');
      ;

      cssPagedMedia.size('portrait');





      So how can i make printing for text-editor show 0 margin and protrait no matter what are the default printing settings in your browser ?










      share|improve this question













      I have a text editor and i want when you print print to see results with no date,link or title thats why i use this script to have 0 margin and portrait






      var cssPagedMedia = (function () 
      var style = document.createElement('style');
      document.head.appendChild(style);
      return function (rule)
      style.innerHTML = rule;
      ;
      ());

      cssPagedMedia.margin = function (margin)
      cssPagedMedia('@page margin: ' + margin + '');
      ;

      cssPagedMedia.margin('0');

      cssPagedMedia.size = function (size)
      cssPagedMedia('@page size: ' + size + '');
      ;

      var cssPagedMedia = (function ()
      var style = document.createElement('style');
      document.head.appendChild(style);
      return function (rule)
      style.innerHTML = rule;
      ;
      ());

      cssPagedMedia.size = function (size)
      cssPagedMedia('@page size: ' + size + '');
      ;

      cssPagedMedia.size('portrait');





      But this script work only on the main page if you tried to print it but not text in text-editor and you can see example



      and i want to apply previous script on the text editor's javascript and this the whole javascript of the text-editor






      var oDoc, sDefTxt;

      function initDoc()
      oDoc = document.getElementById("textBox");
      sDefTxt = oDoc.innerHTML;
      if (document.compForm.switchMode.checked) setDocMode(true);


      function formatDoc(sCmd, sValue)
      if (validateMode()) document.execCommand(sCmd, false, sValue); oDoc.focus();


      function validateMode()
      if (!document.compForm.switchMode.checked) return true ;
      alert("Uncheck "Show HTML".");
      oDoc.focus();
      return false;


      function setDocMode(bToSource)
      var oContent;
      if (bToSource)
      oContent = document.createTextNode(oDoc.innerHTML);
      oDoc.innerHTML = "";
      var oPre = document.createElement("pre");
      oDoc.contentEditable = false;
      oPre.id = "sourceText";
      oPre.contentEditable = true;
      oPre.appendChild(oContent);
      oDoc.appendChild(oPre);
      document.execCommand("defaultParagraphSeparator", false, "div");
      else
      if (document.all)
      oDoc.innerHTML = oDoc.innerText;
      else
      oContent = document.createRange();
      oContent.selectNodeContents(oDoc.firstChild);
      oDoc.innerHTML = oContent.toString();

      oDoc.contentEditable = true;

      oDoc.focus();


      function printDoc()
      if (!validateMode()) return;
      var oPrntWin = window.open("","inlineFrameExample","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></title></head><body onload="print();">"+ "<div dir='rtl'>" + oDoc.innerHTML + "</body></html>");
      oPrntWin.document.close();

      /*page margin*/
      var cssPagedMedia = (function ()
      var style = document.createElement('style');
      document.head.appendChild(style);
      return function (rule)
      style.innerHTML = rule;
      ;
      ());

      cssPagedMedia.margin = function (margin)
      cssPagedMedia('@page margin: ' + margin + '');
      ;

      cssPagedMedia.margin('0');
      /*page size*/
      cssPagedMedia.size = function (size)
      cssPagedMedia('@page size: ' + size + '');
      ;

      var cssPagedMedia = (function ()
      var style = document.createElement('style');
      document.head.appendChild(style);
      return function (rule)
      style.innerHTML = rule;
      ;
      ());

      cssPagedMedia.size = function (size)
      cssPagedMedia('@page size: ' + size + '');
      ;

      cssPagedMedia.size('portrait');





      So how can i make printing for text-editor show 0 margin and protrait no matter what are the default printing settings in your browser ?






      var cssPagedMedia = (function () 
      var style = document.createElement('style');
      document.head.appendChild(style);
      return function (rule)
      style.innerHTML = rule;
      ;
      ());

      cssPagedMedia.margin = function (margin)
      cssPagedMedia('@page margin: ' + margin + '');
      ;

      cssPagedMedia.margin('0');

      cssPagedMedia.size = function (size)
      cssPagedMedia('@page size: ' + size + '');
      ;

      var cssPagedMedia = (function ()
      var style = document.createElement('style');
      document.head.appendChild(style);
      return function (rule)
      style.innerHTML = rule;
      ;
      ());

      cssPagedMedia.size = function (size)
      cssPagedMedia('@page size: ' + size + '');
      ;

      cssPagedMedia.size('portrait');





      var cssPagedMedia = (function () 
      var style = document.createElement('style');
      document.head.appendChild(style);
      return function (rule)
      style.innerHTML = rule;
      ;
      ());

      cssPagedMedia.margin = function (margin)
      cssPagedMedia('@page margin: ' + margin + '');
      ;

      cssPagedMedia.margin('0');

      cssPagedMedia.size = function (size)
      cssPagedMedia('@page size: ' + size + '');
      ;

      var cssPagedMedia = (function ()
      var style = document.createElement('style');
      document.head.appendChild(style);
      return function (rule)
      style.innerHTML = rule;
      ;
      ());

      cssPagedMedia.size = function (size)
      cssPagedMedia('@page size: ' + size + '');
      ;

      cssPagedMedia.size('portrait');





      var oDoc, sDefTxt;

      function initDoc()
      oDoc = document.getElementById("textBox");
      sDefTxt = oDoc.innerHTML;
      if (document.compForm.switchMode.checked) setDocMode(true);


      function formatDoc(sCmd, sValue)
      if (validateMode()) document.execCommand(sCmd, false, sValue); oDoc.focus();


      function validateMode()
      if (!document.compForm.switchMode.checked) return true ;
      alert("Uncheck "Show HTML".");
      oDoc.focus();
      return false;


      function setDocMode(bToSource)
      var oContent;
      if (bToSource)
      oContent = document.createTextNode(oDoc.innerHTML);
      oDoc.innerHTML = "";
      var oPre = document.createElement("pre");
      oDoc.contentEditable = false;
      oPre.id = "sourceText";
      oPre.contentEditable = true;
      oPre.appendChild(oContent);
      oDoc.appendChild(oPre);
      document.execCommand("defaultParagraphSeparator", false, "div");
      else
      if (document.all)
      oDoc.innerHTML = oDoc.innerText;
      else
      oContent = document.createRange();
      oContent.selectNodeContents(oDoc.firstChild);
      oDoc.innerHTML = oContent.toString();

      oDoc.contentEditable = true;

      oDoc.focus();


      function printDoc()
      if (!validateMode()) return;
      var oPrntWin = window.open("","inlineFrameExample","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></title></head><body onload="print();">"+ "<div dir='rtl'>" + oDoc.innerHTML + "</body></html>");
      oPrntWin.document.close();

      /*page margin*/
      var cssPagedMedia = (function ()
      var style = document.createElement('style');
      document.head.appendChild(style);
      return function (rule)
      style.innerHTML = rule;
      ;
      ());

      cssPagedMedia.margin = function (margin)
      cssPagedMedia('@page margin: ' + margin + '');
      ;

      cssPagedMedia.margin('0');
      /*page size*/
      cssPagedMedia.size = function (size)
      cssPagedMedia('@page size: ' + size + '');
      ;

      var cssPagedMedia = (function ()
      var style = document.createElement('style');
      document.head.appendChild(style);
      return function (rule)
      style.innerHTML = rule;
      ;
      ());

      cssPagedMedia.size = function (size)
      cssPagedMedia('@page size: ' + size + '');
      ;

      cssPagedMedia.size('portrait');





      var oDoc, sDefTxt;

      function initDoc()
      oDoc = document.getElementById("textBox");
      sDefTxt = oDoc.innerHTML;
      if (document.compForm.switchMode.checked) setDocMode(true);


      function formatDoc(sCmd, sValue)
      if (validateMode()) document.execCommand(sCmd, false, sValue); oDoc.focus();


      function validateMode()
      if (!document.compForm.switchMode.checked) return true ;
      alert("Uncheck "Show HTML".");
      oDoc.focus();
      return false;


      function setDocMode(bToSource)
      var oContent;
      if (bToSource)
      oContent = document.createTextNode(oDoc.innerHTML);
      oDoc.innerHTML = "";
      var oPre = document.createElement("pre");
      oDoc.contentEditable = false;
      oPre.id = "sourceText";
      oPre.contentEditable = true;
      oPre.appendChild(oContent);
      oDoc.appendChild(oPre);
      document.execCommand("defaultParagraphSeparator", false, "div");
      else
      if (document.all)
      oDoc.innerHTML = oDoc.innerText;
      else
      oContent = document.createRange();
      oContent.selectNodeContents(oDoc.firstChild);
      oDoc.innerHTML = oContent.toString();

      oDoc.contentEditable = true;

      oDoc.focus();


      function printDoc()
      if (!validateMode()) return;
      var oPrntWin = window.open("","inlineFrameExample","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></title></head><body onload="print();">"+ "<div dir='rtl'>" + oDoc.innerHTML + "</body></html>");
      oPrntWin.document.close();

      /*page margin*/
      var cssPagedMedia = (function ()
      var style = document.createElement('style');
      document.head.appendChild(style);
      return function (rule)
      style.innerHTML = rule;
      ;
      ());

      cssPagedMedia.margin = function (margin)
      cssPagedMedia('@page margin: ' + margin + '');
      ;

      cssPagedMedia.margin('0');
      /*page size*/
      cssPagedMedia.size = function (size)
      cssPagedMedia('@page size: ' + size + '');
      ;

      var cssPagedMedia = (function ()
      var style = document.createElement('style');
      document.head.appendChild(style);
      return function (rule)
      style.innerHTML = rule;
      ;
      ());

      cssPagedMedia.size = function (size)
      cssPagedMedia('@page size: ' + size + '');
      ;

      cssPagedMedia.size('portrait');






      javascript jquery css printing text-editor






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 '18 at 23:14









      HAMIDHAMID

      258




      258






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271463%2fapply-script-on-another-function%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271463%2fapply-script-on-another-function%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Barbados

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3