Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.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插入xml(网站)ODOO_Javascript_Xml_Odoo 8 - Fatal编程技术网

如何将javascript插入xml(网站)ODOO

如何将javascript插入xml(网站)ODOO,javascript,xml,odoo-8,Javascript,Xml,Odoo 8,我想从网站下载多张图片,请检查我的javascript和xml代码,我的代码有什么问题? 以及如何将javascript插入xml 这是我的javascript代码 var-zip=newjszip(); var计数=0; var zipFilename=“zipFilename.zip”; 变量URL=[ 'http://weedo.sgeede.com/website/image/product.template/376_339fb36/image', 'http://dota-everyd

我想从网站下载多张图片,请检查我的javascript和xml代码,我的代码有什么问题?
以及如何将javascript插入xml

这是我的javascript代码

var-zip=newjszip();
var计数=0;
var zipFilename=“zipFilename.zip”;
变量URL=[
'http://weedo.sgeede.com/website/image/product.template/376_339fb36/image',
'http://dota-everyday.com/support/image',
'http://dota-everyday.com/omniknight/image'
];
forEach(函数(url){
var filename=“filename”;
//加载文件并将其添加到zip文件中
getBinaryContent(url、函数(err、数据){
如果(错误){
抛出err;//或处理错误
}
文件(文件名,数据,{binary:true});
计数++;
if(count==url.length){
var zipFile=zip.generate({type:“blob”});
saveAs(zipFile,zipFilename);
}
});
});
这是我的xml


要将Javascript插入网站xml,您需要创建一个记录模板,该模板继承网站资产,如下所示-

<template id="custom_assets" inherit_id="website.assets_frontend" name="Custom Assets">
    <xpath expr="." position="inside">
        <script type="text/javascript" src="/...path to your custom js file"></script>
    </xpath>
</template>

您的最终JS将是-

odoo.define(['jszip', 'ods'], function (jszip, ods) {
"use strict";
    var zip = new JSZip();
    var count = 0;
    var zipFilename = "zipFilename.zip";
    var urls = [    
       'http://weedo.sgeede.com/website/image/product.template/376_339fb36/image',
       'http://dota-everyday.com/support/image',
      'http://dota-everyday.com/omniknight/image'
    ];

urls.forEach(function(url){
    var filename = "filename";
    // loading a file and add it in a zip file
    JSZipUtils.getBinaryContent(url, function (err, data) {
    if(err) {
        throw err; // or handle the error
    }
    zip.file(filename, data, {binary:true});
    count++;
    if (count == urls.length) {
        var zipFile = zip.generate({type: "blob"});
        saveAs(zipFile, zipFilename);
    }
});
}));
});

这个问题很不清楚。您需要添加支持文本,以解释您的问题和当前解决问题的方法,并解释预期结果和当前结果。现在,您正在询问如何将Javscript添加到XML中,然后发布一些HTML。除非这个问题得到更好的解释,否则你不太可能得到任何帮助(而且很可能最终被关闭)。你的问题仍然不清楚。为什么要将Javscript插入XML?你能解释一下你想要达到的实际效果,而不是你想要达到的效果吗?对不起,不。这是HTML,不是XML,我不明白你为什么要在其中插入Javscript。检查控制台错误,请与我分享。我看到的是你正在调用一个名为-URL()的函数单击锚定标记。但您还没有在javascript中定义同名函数。这可能是创建控制台错误-未定义URL。我猜是这样的。试着使用类似这样的东西--odoo.define(['jszip'],function(jszip){“use strict”///这里的自定义代码});好的,我会为你写完整的JS。它类似于-odoo.define(['jszip','ods'],function(jszip,ods){“use strict”;//从这里开始使用您的js代码-从-var zip=new jszip();…..saveAs(zipFile,zipFilename);}}}};});JS问题解决了吗?