I am using an external JavaScript lib in my chrome extension. I has inline execution, so I get following kind of error
(The error I get on console)
I've got this problem after I added a simple checkbox on the login page to toggle password visibility and here is how I have fixed my problem, hope it helps;
Before
After
Remember to reference your js file, if you haven't, yet. You can simply reference it like this.
And here is the event listener that I've added into my Script.js.
$(document).ready(function () {
addEventListenerForCheckboxTogglePasswordVisibility()
});
function addEventListenerForCheckboxTogglePasswordVisibility() {
var checkbox = document.getElementById("checkboxTogglePasswordVisibility");
if (checkbox !== null) {
checkbox.addEventListener('click', togglePasswordVisibility);
}
}
function togglePasswordVisibility() {
var passwordElement = document.getElementById("password");
if (passwordElement.type === "password") {
passwordElement.type = "text";
} else {
passwordElement.type = "password";
}
}
Error before the fix;