From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../windoweventhandlers/onbeforeprint/index.html | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 files/ja/web/api/windoweventhandlers/onbeforeprint/index.html (limited to 'files/ja/web/api/windoweventhandlers/onbeforeprint/index.html') diff --git a/files/ja/web/api/windoweventhandlers/onbeforeprint/index.html b/files/ja/web/api/windoweventhandlers/onbeforeprint/index.html new file mode 100644 index 0000000000..3365ee7e4d --- /dev/null +++ b/files/ja/web/api/windoweventhandlers/onbeforeprint/index.html @@ -0,0 +1,69 @@ +--- +title: WindowEventHandlers.onbeforeprint +slug: Web/API/WindowEventHandlers/onbeforeprint +tags: + - API + - DOM + - Event Handler + - HTML DOM + - Reference + - onbeforeprint + - プロパティ + - 印刷 +translation_of: Web/API/WindowEventHandlers/onbeforeprint +--- +
{{ApiRef}}
+ +

{{domxref("WindowEventHandlers")}} ミックスインの onbeforeprint プロパティは、現在のウィンドウの {{event("beforeprint")}} イベントを処理するための {{domxref("EventHandler")}} です。 このイベントは、印刷ダイアログウィンドウが開く前に発生します。

+ +

beforeprint イベントと {{event("afterprint")}} イベントを使用すると、印刷を開始する前にページでコンテンツを変更し(例えば、バナーを削除するなど)、印刷の完了後にそれらの変更を元に戻すことができます。 一般に、@media print CSS @-規則の使用を好むはずですが、場合によってはこれらのイベントを使用する必要があるかもしれません。

+ +

構文

+ +
window.addEventListener("beforeprint", function(event) { ... });
+window.onbeforeprint = function(event) { ... };
+
+ +

ポリフィル

+ +

Safari はこれらのイベントを実装していませんが、{{domxref("window.matchMedia")}}('print') を使用して beforeprint イベントと同等の結果を作成できます。

+ +
var mediaQueryList = window.matchMedia('print');
+mediaQueryList.addListener(function(mql) {
+  if(mql.matches) {
+    console.log('onbeforeprint に相当する webkit');
+  }
+});
+ +

仕様

+ + + + + + + + + + + + + + + + +
仕様状態コメント
{{SpecName('HTML WHATWG', '#handler-window-onbeforeprint', 'onbeforeprint')}}{{Spec2('HTML WHATWG')}}
+ +

ブラウザーの互換性

+ + + +

{{Compat("api.WindowEventHandlers.onbeforeprint")}}

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf