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
- How to change CSS using jQuery?
- How to properly use jsPDF library
- Cannot set property InnerHTML of null [duplicate]
- jQuery document.createElement equivalent?
- jQuery Get Selected Option From Dropdown
- Remove CSS class from element with JavaScript (no jQuery) [duplicate]
- (change) vs (ngModelChange) in angular
- Export html table data to Excel using JavaScript / JQuery is not working properly in chrome browser
- How to generate a simple popup using jQuery
- TypeError: Cannot Set property ‘onclick’ of null
- Bootstrap Dropdown menu is not working
- Bootstrap Dropdown menu is not working
- Create table with jQuery – append
- How would I call a javascript function in html?
- “.addEventListener is not a function” why does this error occur?
- Coin toss with JavaScript and HTML
- Play an audio file using jQuery when a button is clicked
- getBoundingClientRect is not a function
- document.getElementsByClassName().innerHTML always returns “undefined”
- Jquery button click() function is not working
- Make iframe automatically adjust height according to the contents without using scrollbar?
- How do I modify the URL without reloading the page?
- Error: ENOENT: no such file or directory, stat ‘/public/main.html’ at Error (native)
- How do I check whether a checkbox is checked in jQuery?
- How to get the selected radio button’s value?
- Creating a div element in jQuery
- document.getElementById().value doesn’t set the value
- How to run a function when the page is loaded?
- Clearing my form inputs after submission
- Get class list for element with jQuery
- Reload an iframe with jQuery
- HTML/Javascript change div content
- Video auto play is not working in Safari and Chrome desktop browser
- How can I use jQuery to run MySQL queries?
- anchor jumping by using javascript
- FormData append not working
- Set CSS property in JavaScript?
- What’s the effect of adding ‘return false’ to a click event listener?
- Getting or changing CSS class property with Javascript using DOM style
- “Uncaught TypeError: Illegal invocation” in Chrome
- How do I clear the content of a div using JavaScript?
- The value of attribute [ data-type ] must be in double quotes – custom html widget error
- Adding JavaScript to a WordPress website
- Insert “javascript:void(0);” into URL
- How to integrate my HTML and javascript into my child theme
- Add Codepen animation as Preloader to WordPress
- Cannot set property ‘className’ of null at setThemeFromCookie
- Adding a Calculator to a WordPress Page
- Link to page with posts of specific type
- how to let users upload their custom cover image
- Overriding inline !important CSS with Javscript code snippet with media query
- Getting click on item to open closest relevant element (popup) with jQuery
- Target a specific container to style on WordPress storefront theme
- How to delay display of page elements until enqueued script has injected html
- Possible jquery / library conflict in plugin usage
- Why the images on mi javascript are not found?
- dropdown does not work [closed]
- How do I cycle a JS function in WordPress? [closed]