我能夠在除圖像之外的彈出窗口上顯示所有表單域。圖像直接顯示在表單上。在提交之前,它也應該顯示在彈出窗口和其他字段中。在使用javascript上傳之前在彈出窗口中預覽圖像
function openPreview()
{
var title = document.getElementById("title").value;
var msg= document.ElementByClassName("nicEdit-main")[0].innerHTML;
var category = document.getElementById("category").value;
var status = document.getElementById("status").value;
var oFReader= new FileReader();
oFReader.readAsDataURL(document.getElementById("fileupload").files[0]);
oFReader.onload = function (oFREvent) {
document.getElementById("uploadPreview").src = oFREvent.target.result;
};
var popWin=window.open(title, 'Preview_Entry');
popWin.document.write('Title:' + title + '<br /> Message:' + msg + '<br /> Category: ' + category + '<br /> Status:' + status + oFReader);
}
您正在設置主窗口上圖像的「src」。相反,你應該在彈出窗口上創建一個圖像標籤,並將其設置爲'src' –
我創建了一個var並將其寫入popWin.document.write中。但我正面臨着顯示它的問題。 popWin.document.write('標題:'+標題+'
消息:'+ msg +'
分類:'+ category +'
狀態:'+ status + imgUrl); – Rev