I am trying to find a fallback solution for browsers who do not interpret the placeholder attribute for input elements.
I have this simple jQuery Script but it throws an Error
SecurityError: "The operation is insecure.
this.value = val;"
Here’s my script:
$('document').ready(function(){
$('input').each(function() {
if ($(this).val() === '' || $(this).val() === undefined) {
$(this).val($(this).attr('placeholder'));
}
});
});
Anyone any ideas what i can do? Or what i am doing wrong? Or what this error means?
It happens in Firefox, haven’t tested it in other Browsers yet.
I have just fixed a similar problem in my project. It turned out that I was trying to set a value of a
<input type="file" ...>input. It seems that you may be facing the same problem, because you are selecting all inputs of a document regardless of their type.If you have firebug installed, try looking for the input that causes this error by inserting a
logcommand before trying to modify the input’s value.