Javascript 为什么vBulletin在其js提要中返回函数?
如果加载vBulletin(3.6.8)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;
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联合。