jQuery:Javascript抛出错误“;操作不安全”;设置值时
jQuery: Javascript throws Error "The operation is insecure" when setting value
我正试图为那些不解释输入元素占位符属性的浏览器找到一个后备解决方案。我有这个简单的jQuery脚本,但它抛出了一个错误
SecurityError: "The operation is insecure.
this.value = val;"
这是我的脚本:
$('document').ready(function(){
$('input').each(function() {
if ($(this).val() === '' || $(this).val() === undefined) {
$(this).val($(this).attr('placeholder'));
}
});
});
有人知道我能做什么吗?或者我做错了什么?或者这个错误意味着什么?它发生在Firefox中,还没有在其他浏览器中测试过。
我刚刚修复了项目中的一个类似问题。事实证明,我正试图设置<input type="file" ...>
输入的值。您可能会面临同样的问题,因为您要选择文档的所有输入,而不管它们的类型如何。
如果您安装了firebug,请在尝试修改输入值之前插入log
命令,尝试查找导致此错误的输入。
$('document').ready(function(){
$('input').each(function() {
if ($(this).val() === '' || $(this).val() === undefined) {
// Log goes here
window.console.log(
'There is an input without a value!',
this);
$(this).val($(this).attr('placeholder'));
}
});
});
我在其他函数中收到了一个不安全的警告。原因很简单,调用库函数时将数组作为参数,但它需要一个元素(dom)。结果是意料之中的,但我确信,无论如何都不会这样。因此,请检查您的变量类型是否是您(或另一方)想要的类型。
相关文章:
- CORS保持在SecurityError上:操作不安全
- createObjectURL blob url在Firefox中不安全
- Redux:为什么不把操作和reducer放在同一个文件中呢
- SecurityError:操作在canvas.toDataURL中不安全
- jQuery:Javascript抛出错误“;操作不安全”;设置值时
- HTML5历史API-操作不安全
- 操作不安全-watermark.js
- Firefox 安全错误:“操作不安全
- 错误:操作不安全.图片未在亚马逊服务器网址的画布 base64 中转换
- 部署Google Chrome扩展;Adobe Flash Player已停止一项可能不安全的操作
- JavaScript弹出“该操作不安全”
- SecurityError:操作不安全.当使用AjaxUpload库
- 新建文件()—该操作不安全
- Firefox localstorage from ifrage - SecurityError:该操作不安全
- SecurityError:当我试图从其他服务器访问镜像时,操作是不安全的
- SecurityError:操作不安全.未捕获的ReferenceError: openDialog is not de
- Firefox扩展中的localStorage抛出“;操作不安全"例外
- 如何防止“;操作不安全”;在页面中动态插入javascript时发出警告
- 得到"操作不安全”;通过tinymce添加tinymce时出错.EditorManager.execComma
- 安全错误:操作不安全.使用 Htmlcanvas