如何通过Javascriptdynamic创build表单

我的网站Aweberregistry格收到很多垃圾邮件。 我被告知有通过JavaScriptdynamic创build的forms。 我将如何通过JavaScript创build一个表单?

有些东西如下::

在body标签后添加这个

这是一个粗略的草图,您将需要根据您的需要进行修改。

<script> var f = document.createElement("form"); f.setAttribute('method',"post"); f.setAttribute('action',"submit.php"); var i = document.createElement("input"); //input element, text i.setAttribute('type',"text"); i.setAttribute('name',"username"); var s = document.createElement("input"); //input element, Submit button s.setAttribute('type',"submit"); s.setAttribute('value',"Submit"); f.appendChild(i); f.appendChild(s); //and some more input elements here //and dont forget to add a submit button document.getElementsByTagName('body')[0].appendChild(f); </script>