I want to print some HTML content, when the user clicks on a button. Once the user clicks on that button, the print dialog of the browser will open, but it will not print the webpage. Instead, it will print the some other HTML content which is not displayed on the page.
While asking this question, there are few solutions coming into my mind. But I am not sure whether those are good ideas or something better can be done. One of those solutions are: I can keep this HTML content in a div and make it display:
to print, but display: none
to screen. All other elements on the webpage can be made to display: none
for print and display:
for the screen. And then call to print.
Any better idea?
Related Posts:
- Failed to load resource: the server responded with a status of 404 (Not Found)
- Failed to load resource: the server responded with a status of 404 (Not Found)
- How can I scroll to an element using jQuery?
- What is the meaning of == $0 that is shown in inspect element of google chrome for the selected element [duplicate]
- Bootstrap Dropdown menu is not working
- Change Background color (css property) using Jquery
- Set timeout for ajax (jQuery)
- How does the data-toggle attribute work? (What’s its API?)
- CSS height 100% percent not working
- Use images like checkboxes
- Completely disable scrolling of webpage
- Uncaught TypeError: Cannot read property ‘top’ of undefined
- Full-screen iframe with a height of 100%
- Bootstrap 4 Dropdown Menu not working?
- Why is the jquery script not working?
- Textarea Auto height
- Why is marquee deprecated and what is the best alternative?
- Refresh/reload the content in Div using jquery/ajax
- Print the contents of a DIV
- How to write inside a DIV box with javascript
- How to get height of div in px dimension
- Crop the image using JavaScript
- Force div to be topmost element of any and all webpages
- Retrieve the position (X,Y) of an HTML element
- How to display raw JSON data on a HTML page
- how to display a div triggered by onclick event
- Why is jquery show() not working in example
- jQuery scrollTop() method not working
- Change an image with onclick()
- Print a div content using Jquery
- JavaScript – Count Number of Visitor for Website
- Creating Accordion Table with Bootstrap
- Fully responsive HTML5 video
- How to create checkbox inside dropdown?
- Positioning element at center of screen
- Adding Google Translate to a web site
- Cannot read property ‘style’ of undefined — Uncaught Type Error
- How to make HTML element resizable using pure Javascript?
- How to use aria-expanded=”true” to change a css property
- How to set “style=display:none;” using jQuery’s attr method?
- WordPress Bootstrap Handburger Menu Wont Open
- Hide CSS class only in single post pages
- Maximum call stack size exceeded error
- How to change CSS using jQuery?
- How to properly use jsPDF library
- Can I use complex HTML with Twitter Bootstrap’s Tooltip?
- Angular: conditional class with *ngClass
- Google Chrome Uncaught (in promise) DOMException while playing AUDIO
- How to make a word underline in Markdown
- ChartJS beginAtZero, min, max doesn’t work
- How do I check whether a checkbox is checked in jQuery?
- how to fix : ” TypeError: Cannot read property ‘addEventListener’ of null”…?//
- Cannot set property InnerHTML of null [duplicate]
- ReferenceError: $ is not defined
- How to fix “Cannot read property ‘addEventListener’ of null” error [duplicate]
- React.js: Set innerHTML vs dangerouslySetInnerHTML
- Remove class using jQuery
- How do I check whether a checkbox is checked in jQuery?
- jQuery document.createElement equivalent?
- (Google Map API) Geocode was not successful for the following reason: REQUEST_DENIED
- How to make a word underline in Markdown
- Pure JavaScript equivalent of jQuery’s $.ready() – how to call a function when the page/DOM is ready for it [duplicate]
- How to play audio?
- How to play audio?
- jQuery.click() vs onClick
- jQuery Get Selected Option From Dropdown
- Remove CSS class from element with JavaScript (no jQuery) [duplicate]
- Include another HTML file in a HTML file
- Check if checkbox is checked with jQuery
- Set cookie and get cookie with JavaScript
- Add swipe left/right to web page, but use default swipe up/down
- How to add jQuery code into HTML Page
- How can I get the data-id attribute?
- Check if checkbox is checked with jQuery
- “Uncaught TypeError: Cannot read property ‘style’ of null at.. “
- How to resolve the C:\fakepath?
- Angular: mat-form-field must contain a MatFormFieldControl
- (change) vs (ngModelChange) in angular
- jquery SlideToggle effect in upward direction?
- Failed to load resource: net::ERR_FILE_NOT_FOUND loading json.js
- Get class name using jQuery
- How to clear the canvas for redrawing
- Adding options to select with javascript
- Using Javascript in CSS
- Export html table data to Excel using JavaScript / JQuery is not working properly in chrome browser
- How to generate a simple popup using jQuery
- How to change css property using javascript
- JavaScript get element by name
- Adding images to a Bootstrap Carousel with AJAX
- How to read xml file contents in jQuery and display in html elements?
- HTML5 Local storage vs. Session storage
- JavaScript Loading Screen while page loads
- TypeError: Cannot Set property ‘onclick’ of null
- Express Render not working return error: No default engine was specified and no extension was provided
- How do I scroll to an element using JavaScript?
- Angular: conditional class with *ngClass
- Jquery swipe left or right on mobile
- Programmatically change the src of an img tag
- display variable image using cookies
- How to move an element into another element?