如何无头地运行 JavaScript?
我正在寻找像 Scratchpad(存在于 Firefox 中)这样的选项,它可以运行 JavaScript 并在没有浏览器的特定网站上进行 DOM 操作,并且最好从命令行执行。
我获得了亚马逊产品 API 的批准,并且正在 ScratchPad 中进行了几次测试调用,但它不断返回错误:
Error! TooManyRequests The request was denied due to request throttling. Please verify the number of requests made per second to the Amazon Product Advertising API.
我从来没有收到过好的回应。我已经与他们的支持人员交谈了一个多星期,但没有人提供任何帮助,只是说“看起来不错,我不知道为什么你会得到这样的回应”
我正在使用js来改变内容输入的div的内容我希望用它们与Ajax一起使用,我使用Firefox暂存器来调试这个函数:
function show(id){
var div = document.getElementById('com');
div.innerHTML = '';
var input1 = document.createElement('input')
.createAttribute('type').setAttribute('type', 'hidden')
.createAttribute('value').setAttribute('value',id )
.setAttribute('name','id' );
var input2 = document.createElement('input')
.createAttribute('type').setAttribute('type', 'input')
.createAttribute('name').setAttribute('name', 'com');
var btn = document.createElement('button')
.createAttribute('onClick').setAttribute('onClick', 'post()');
btn.innerHTML = 'Comment';
div.appendChild(input1).appendChild(input2).appendChild(btn);
}
Run Code Online (Sandbox Code Playgroud)
我得到的是这个:
/*
Exception: document.createElement(...).createAttribute is not a function
@Scratchpad/2:2
*/
Run Code Online (Sandbox Code Playgroud)
我什么都不懂,有什么想法?