javascript動態創建Form表單和表單項,然后提交表單請求,最后刪除表單,代碼片段如下(Firefox測試通過):
var dlform = document.createElement('form'); dlform.style = "display:none;"; dlform.method = 'post'; dlform.action = '../fileServlet'; dlform.target = 'callBackTarget'; var hdnFilePath = document.createElement('input'); hdnFilePath.type = 'hidden'; hdnFilePath.name = 'filePath'; hdnFilePath.value = filePath; dlform.appendChild(hdnFilePath); document.body.appendChild(dlform); dlform.submit(); document.body.removeChild(dlform);
<end>
