Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/438.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 为什么vBulletin在其js提要中返回函数?_Javascript_Node.js_Vbulletin - Fatal编程技术网

Javascript 为什么vBulletin在其js提要中返回函数?

Javascript 为什么vBulletin在其js提要中返回函数?,javascript,node.js,vbulletin,Javascript,Node.js,Vbulletin,如果加载vBulletin(3.6.8)js提要,例如,您将得到如下输出: function thread(threadid, title, poster, threaddate, threadtime) { this.threadid = threadid; this.title = title; this.poster = poster; this.threaddate = threaddate; this.threadtime = threadtime;

如果加载vBulletin(3.6.8)js提要,例如,您将得到如下输出:

function thread(threadid, title, poster, threaddate, threadtime) {
   this.threadid = threadid; 
   this.title = title; 
   this.poster = poster;
   this.threaddate = threaddate; 
   this.threadtime = threadtime; 
} 

var threads = new Array(15); threads[0] = new thread(370145, ...rest of threads in an array...);
考虑到eval()可能不安全,这个函数对象有什么用途,从javascript(Node.JS)计算这个JS的安全方法是什么

var phantom = require('phantom');
phantom.create(function(ph) {
    return ph.createPage(function(page) {
        return page.open("http://www.example.com/forum/external.php?type=js&forumids=1&lastpost=1", function(status) {
            console.log("opened page? ", status);
            return page.get('plainText', function(content){
                console.log(content);
                eval(content); //danger!
                console.log(thread);

                return ph.exit();
            });
        });
    });
});

您可以从外部将其加载到
脚本
标记中,然后访问
线程
数组

<script src="/path/to/external.php"></script>
<script>
    threads.forEach(function(thread) {
        //do something with thread, has the objects listed in thread()
    }
</script>

forEach(函数(线程){
//使用thread做一些事情,将对象列在thread()中
}

您可以将其加载到外部的
脚本
标记中,然后访问
线程
数组

<script src="/path/to/external.php"></script>
<script>
    threads.forEach(function(thread) {
        //do something with thread, has the objects listed in thread()
    }
</script>

forEach(函数(线程){
//使用thread做一些事情,将对象列在thread()中
}

谢谢-我应该提到我在Node.js中做这件事,而不是在浏览器中。然后我会使用XML联合。谢谢-我应该提到我在Node.js中做这件事,而不是在浏览器中。然后我会使用XML联合。