diff --git a/DuckDuckGo/BrowserTab/Model/PrintingUserScript.swift b/DuckDuckGo/BrowserTab/Model/PrintingUserScript.swift index 10afba91e9..a37df3c78d 100644 --- a/DuckDuckGo/BrowserTab/Model/PrintingUserScript.swift +++ b/DuckDuckGo/BrowserTab/Model/PrintingUserScript.swift @@ -33,11 +33,10 @@ public class PrintingUserScript: NSObject, UserScript { public var source: String = """ (function() { document.addEventListener("click", function(event) { - event = event || window.event; let onClickAttribute = event.target.getAttribute('onclick'); - if (onClickAttribute.includes('window.print()')) { + if (onClickAttribute && onClickAttribute.includes('window.print()')) { webkit.messageHandlers.printHandler.postMessage({}); } });