Skip to content

Commit 3df864f

Browse files
authored
Merge pull request #1729 from companieshouse/origin/fix/roe-635/print-button-no-longer-functions-on-check-your-answers
roecct-635/Print button no longer functions on check your answers
2 parents 4827350 + d417b0f commit 3df864f

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

views/includes/print-button.html

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,24 @@
1818
{{ govukButton({
1919
text: "Print this page",
2020
classes: "govuk-button--secondary",
21-
href: "javascript: window.print()",
2221
attributes: {
23-
"id": "print-button",
24-
"data-event-id": "print-button"
22+
id: "print-button",
23+
"data-event-id": "print-button",
24+
type: "button"
2525
}
2626
}) }}
2727

28-
<p class="govuk-body govuk-!-font-size-20 check-your-answers-javascript-disabled-text-style">To print this page, select print from your browser menu.</p>
28+
<p class="govuk-body govuk-!-font-size-20 check-your-answers-javascript-disabled-text-style">
29+
To print this page, select print from your browser menu.
30+
</p>
31+
32+
<script nonce={{ cspNonce | dump | safe }}>
33+
document.addEventListener('DOMContentLoaded', function () {
34+
var printButton = document.getElementById('print-button');
35+
if (printButton) {
36+
printButton.addEventListener('click', function () {
37+
window.print();
38+
});
39+
}
40+
});
41+
</script>

0 commit comments

Comments
 (0)