javascript - 如何在 JavaScript 中动态生成表单?
问题描述
我在 javascript 中动态创建了图像(记录器缩略图)。我想将此图像的图像路径发送到另一个文件。
我想我无法获得图像 ID。我根本无法转到另一个文件。图像已关闭。
window.onload = function() {
var message = {id : 'vodList'}
sendMessage(message);
document.getElementById(bb).addEventListener('click', function() { vodPlayer(); });
}
ws.onmessage = function(message) {
for (var i=0; i<parsedMessage2.length; i++){
createImage = document.createElement("img");
createImage.setAttribute('src', parsedMessage2[i].vod_thumbnail);
createImage.setAttribute('alt', '100%x280');
createImage.setAttribute('height', '280px');
createImage.setAttribute('width', '100%');
createImage.setAttribute('id', 'vodThumbnailId');
document.getElementById('vodListId').appendChild(createImage);
vodPath = JSON.stringify(parsedMessage2[i].vod_path);
}
}
function vodPlayer() {
var form = document.createElement('form');
form.setAttribute('charset', 'UTF-8');
form.setAttribute('method', 'Post');
form.setAttribute('action', 'vodPlayer.html');
var hiddenField = document.createElement('input');
hiddenField.setAttribute('type', 'hidden');
hiddenField.setAttribute('name', 'vodPath');
hiddenField.setAttribute('value', vodPath);
form.appendChild(hiddenField);
document.body.appendChild(form);
form.submit();
}
我希望你能帮助我。
解决方案
推荐阅读
- java - 客户端似乎在服务器不接受的情况下已连接
- json - 如何使用presto查询位于s3的json文件
- jenkins - 传递环境。作业失败后下游作业的变量
- c++ - 递归除法和 impera 二进制搜索中的错误
- python - 以编程方式将混合关键字非关键字参数传递给 Python 中的绑定方法
- rust - 为什么编译器会以不同的方式处理这两个等效(?)行?
- google-cloud-platform - 有没有办法触发 Google Cloud Storage 下载对象事件?
- java - 重绘线程不会重绘内部类 JPanel
- c++ - 如何在 Win / macOS Qt 项目中引用外部文件,即图像?
- oop - 什么是飞镖中的助手类?