Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 操作不安全-watermark.js_Javascript_Php_Jquery_Wordpress_Watermark - Fatal编程技术网

Javascript 操作不安全-watermark.js

Javascript 操作不安全-watermark.js,javascript,php,jquery,wordpress,watermark,Javascript,Php,Jquery,Wordpress,Watermark,我在WordPress网站上使用watermark.js进行图像保护 测试时,我在img.src=gcanvas.toDataURL()中发现了一个错误。我试图找到在哪里设置此值,但到目前为止一直失败 这就是我正在使用的代码-有人能看到出了什么问题吗 代码 var load = false; window.onload = function(){ if(!load) { wmark.init({ /* config

我在WordPress网站上使用watermark.js进行图像保护

测试时,我在img.src=gcanvas.toDataURL()中发现了一个错误。我试图找到在哪里设置此值,但到目前为止一直失败

这就是我正在使用的代码-有人能看到出了什么问题吗

代码

var load = false;
    window.onload = function(){
        if(!load) {
            wmark.init({
                /* config goes here */
                "position": "top-center", // default "bottom-right"
                "opacity": 50, // default 50
                "className": "watermark", // default "watermark"
                                    "path": "<?php echo WP_PLUGIN_URL.'/'. dirname(plugin_basename( __FILE__ ));?>/images/watermark.png", // plugindir
            });


            load = true;
        }
    }
var负载=false;
window.onload=函数(){
如果(!加载){
wmark.init({
/*配置在这里*/
“位置”:“上中”//默认为“右下”
“不透明度”:50,//默认值50
className:“水印”//默认为“水印”
“路径”:“/images/watermark.png”,//plugindir
});
负载=真;
}
}

最后,我研究了自己,并将其实现为工作解决方案。最后,在这里,它是最好的,而不是dom。请删除dom并尝试一下,它应该会起到作用

<script  type="text/javascript">

               jQuery('img').each(function($) {
                  jQuery(this).attr('class','watermark'); 

               });
                        wmark.init({
                    /* config goes here */
                    "position": "top-center", // default "bottom-right"
                    "opacity": 50, // default 50
                    "className": "watermark", // default "watermark"
                    "path": "watermark.png", // plugindir
                });

            </script>

jQuery('img')。每个(函数($){
jQuery(this.attr('class','watermark');
});
wmark.init({
/*配置在这里*/
“位置”:“上中”//默认为“右下”
“不透明度”:50,//默认值50
className:“水印”//默认为“水印”
“路径”:“watermark.png”,//plugindir
});

为什么要检查
加载
窗口。当窗口加载时,加载设置为
时,每次为
时,加载
只会发生一次。简言之,我认为它永远不会处于这种状态。@Jai现在我明白你说的了。但问题是路径不安全。@Jai SecurityError:操作不安全。img.src=gcanvas.toDataURL();