diff --git a/src/html5-qrcode-scanner.ts b/src/html5-qrcode-scanner.ts
index 028262fe..6e7e949e 100644
--- a/src/html5-qrcode-scanner.ts
+++ b/src/html5-qrcode-scanner.ts
@@ -999,7 +999,9 @@ export class Html5QrcodeScanner {
private resetHeaderMessage() {
const messageDiv = document.getElementById(
this.getHeaderMessageContainerId())!;
- messageDiv.style.display = "none";
+ if(messageDiv){
+ messageDiv.style.display = "none";
+ }
}
private setHeaderMessage(