Tuesday, January 9, 2018

How To Print Window In Html

Hello Friends My Name Is Viraj,Today I Will Print Window On Your Web Page.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.The user can click on a link or button in the HTML page or form, e.g. add the following HTML code:href="javascript:window.print()">Print</a>The problem is, that the print command will print the whole page, which might not be useable.The solution is to define 2 different CSS styles for the screen and the printer, so that unwanted parts of the page will be hidden when printing.While asking this question, there are few solutions coming into my mind.You can set up the ability for users to print specific parts of your web page using a print button or link. You can do this by adding a print.css file to your site, calling it in the head of your HTML document and then defining those sections you want to make easily printable by defining a class. 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.The JavaScript syntax used to simulate the print button currently only works in all modern browsers, so it can be a valid substitute inside a browser window where the toolbars are disabled.The following sample should illustrate how easy it works!

The page contains 3 parts: header, middle and footer and only the middle part should be printed.Write a JavaScript function to print the contents of the current window.window.print(): The window object represents a window containing a DOM document; the document property points to the DOM document loaded in that window, window.print() is used to open the Print Dialog to print the current document.CSS (cascading style sheets) give you considerable control over how content on your web pages is displayed on the screen. This control extends to other media as well, such as when the web page is printed.You may be wondering why you would want to add a print feature to your web page; after all, most people already know or can easily figure out how to print a web page using their browser's menus.

But there are situations where adding a print button or link to a page will not only make the process easier for your users when they need to print out a page, ​but, perhaps even more importantly, give you more control over how those printouts will appear on paper.​Here In This Html Tutorial We Will Create How To Print Window In Html/Javascript Code.Here In This Blog We Will Create How To Print Window In Html/Javascript Code.

Here Is An Example Related To Topic..........

Step 1 :

<!DOCTYPE html>
<html>
<body>

<p>Click the button to print the current page.</p>

<button onclick="myFunction()">Print this page</button>

<script>
function myFunction() {
    window.print();
}
</script>

</body>
</html>

Output :





No comments:

Post a Comment

How To Create Image Gallery In Html

Hello Friend My Name Is Viraj,Today I Will Create Image Gallery And Display On A Webpage.The emergence of CSS3 technology has enabled web d...