How to use Javascript for a popup in a new window with ONLY the same html as the parent window

I want to create several versions of pages for printing from one page. I am going to do it this way: by placing several buttons on the original page and clicking one button, you will see a new window with the same html as its parent window, but with some changes (for example, set the display attribute of some DIV to none).

Can javascript be used for this?

+3
source share
2 answers

You can pass an additional parameter to the current page URL and open it in a new window, for example:

window.open(document.location.href + "?print=true");

URL JavaScript CSS, . ​​

: CSS , ? , :

window.print();

HEAD:

<link rel="stylesheet" href="yourcssfile.css" media="print" /> 

CSS , , . . CSS.

+4

, javascript, :

window.open('myPage.html')

getElementById('<someid>').style.display = none

CSS, CSS div hidings whatnot. , . , .

, , ​​:

<link rel="stylesheet" type="text/css" media="print" href="myPrintStyles.css"/>
+1

Source: https://habr.com/ru/post/1738820/


All Articles