Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7868729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:05:36+00:00 2026-06-03T01:05:36+00:00

I have created a greasemonkey script for the purpose of: Add print receipt button

  • 0

I have created a greasemonkey script for the purpose of:

  • Add print receipt button to 3rd party web app page
  • Add receipt printer friendly styles to div in new window
  • print this window

The button shows up, but it doesn’t trigger my function, which at this point just prints the div.

Here’s where I’m at:

var scriptElement = document.createElement('script');
scriptElement.type = 'text/javascript';

scriptElement.innerHTML =  'function printReceipt() { \
var divToPrint=document.getEelementById("loanTable"); \
newWin= window.open(""); \
newWin.document.write(divToPrint.outerHTML); \
newWin.print(); \
newWin.close(); \
}';

document.getElementsByTagName("head")[0].appendChild(scriptElement);

window.addButton = function () {
    // Get the location on the page where you want to create the button
    var targetDiv = document.getElementById('newcheckout');

    // Create a div to surround the button
    var newDiv = document.createElement('div');
    newDiv.setAttribute('id', 'autoCheckOrder');

    // Create the button and set its attributes
    var inputButton = document.createElement('input');
    inputButton.name = 'autoCheckOrderButton';
    inputButton.type = 'button';
    inputButton.value = 'Print Receipt?';
    inputButton.setAttribute("onclick", "printReceipt();");

    // Append the button to the div
    newDiv.appendChild(inputButton); 
    targetDiv.appendChild(newDiv);
}
addButton();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:05:38+00:00Added an answer on June 3, 2026 at 1:05 am

    There is a typo on this line:

    var divToPrint=document.getEelementById("loanTable"); \
    

    Change it to:

    var divToPrint=document.getElementById("loanTable"); \
    


    Alternately, add this line to your script’s metadata section:

    // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
    

    Then the whole script becomes:

    $("#newcheckout").append ('<div id="autoCheckOrder"></div>');
    $("#autoCheckOrder").append ('<button>Print Receipt?</button>');
    
    $("#autoCheckOrder button").click ( function () {
        var divToPrint  = document.getElementById ("loanTable"); 
        var newWin      = window.open (""); 
        newWin.document.write (divToPrint.outerHTML); 
        newWin.print(); 
        newWin.close(); 
    } );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a Greasemonkey script that runs fine in the firebug editor, with
I have created a PHP-script to update a web server that is live inside
I've created a Greasemonkey script which replaces a page function: (function() { var oldFunc
I have created a simple web service called TimeServerBean . It's working properly, the
Have created a small two tab app, then subclassed another view controller to create
I have created a Resource File as App.rrc(Root)and App_fr.rrc under App.rrh(header file) and have
I have created a page that allows a user to enter a start location
I have written a greasemonkey script which will do GM_xmlhttpRequest to the next 2
Recently I've been working on a Greasemonkey script that would add an image to
I have created a PHP form, which, upon submission, goes to another PHP page.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.