我很難弄清楚我錯了什麼。我在網上搜索了幾個小時,但沒有運氣。這是我的情況。我正在運行移動設備應用程序,我正在將表單(本地)加載到iframe中。然後iam(onload)嘗試將值插入到我的表單文本框中。這裏是代碼使用javascript將值輸入到html表格中
<iframe name="myframe"id="myframe"
src="file:///C:/Users/denise/Desktop/updateform.html"
width=480px height=400px frameborder=1></iframe>
以及JavaScript函數
function imLoaded(){
var ifrm = document.getElementById('myframe');
var form = doc.getElementById('updateform');
form.document.getElementById("updateform").user.value = 'hello';
}
您是否嘗試更新iframe中的值?我相信你需要使用'contentDocument'來訪問東西。例如:'document.getElementById('myframe')。contentDocument.body' – AtheistP3ace
'doc'? 'form.document'? '.user.value'?此代碼看起來非常隨機... – David
@INOH試試我的答案它爲你工作。 – Ansari