开发者

Unable to include Javascript ReferenceError: "window" is not defined

I am trying to use an external JavaScript library in a YQL table because I want to use the MD5 function this library provides. Here is the part of my <execute> block where I try to include the external JavaScript:

        <execute><![CDATA[
            // MD5 hashing from crypto-js
            y.include("http://crypto-js.googlecode.com/files/2.3.0-crypto-md5.js");

            var sig2 = Crypto.MD5("test string", {asString: true});
            y.log(sig2);

            ]]></execute>

When I try to use this YQL t开发者_开发问答able then I get the following error message:

Exception: Unable to include Javascript http://crypto-js.googlecode.com/files/2.3.0-crypto-md5.js, ReferenceError: "window" is not defined.

Apparently the JavaScript library is extending the window object of the DOM with an additional Crypto object.

Now my question is, can I use such a JavaScript library with YQL at all?


YQL crypto object provides a function just for that. It's not documented but you can use:

<execute><![CDATA[

    var sig2 = y.crypto.encodeMd5Hex('test string');
    y.log(sig2);

]]></execute>

Source: http://www.inerciasensorial.com.br/2012/06/01/programacao/javascript/md5-in-yql-in-hexadecimal-form-using-javascript/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜