要在Chrome地址栏中使用JavaScript发送已经编写的文本,您可以使用JavaScript的prompt函数进行交互。下面是一个包含代码示例的解决方法:
javascript:var text = prompt('请输入文本'); if (text !== null && text !== '') { var form = document.createElement('form'); form.method = 'POST'; form.action = 'https://example.com'; var input = document.createElement('input'); input.type = 'hidden'; input.name = 'text'; input.value = text; form.appendChild(input); document.body.appendChild(form); form.submit(); }
https://example.com
发送一个POST请求,其中包含名为text
的隐藏输入字段,其值为您输入的文本。请注意,您需要将https://example.com
替换为您要将文本发送到的实际URL。另外,这种方法只适用于简单的文本发送,如果您需要发送更复杂的数据或进行其他操作,请考虑使用其他方法。
下一篇:按下回车键触发点击事件