2011-03-22 42 views
0
var selwindow = window.open('child1.html','_blank','resizable=yes,width='+(screen.width-500)+',height='+(screen.height-500)+''); 
selwindow.document.selectform.childText.value=document.getElementById('pdetails1').value; 

我正在使用此代碼爲子窗口中的文本框分配一個值。它在Internet Explorer中運行良好,但在Firefox中運行時顯示錯誤。它顯示:selwindow.document.selectform is undefined如何爲子窗口分配值?

這裏,childText是當前窗口的文本框的ID,並pdetails1是子窗口的文本框的ID

回答

1

我假設selectform是在頁面的東西的名稱/ ID。

IE實際上並沒有使用JavaScript,它使用jScript。 jScript將所有名稱/ ids轉換爲全局變量,以便代碼可以工作,但在IE以外的任何地方都無法工作。

嘗試:

selwindow.document.getElementById('selectform').childText.value = ... 

如果表格沒有一個id,給它一個:

<form id="selectform" /> 
+0

我試過,但它顯示selwindow.document.getElementById( 'selectform')爲空 – Prabakaran 2011-03-22 04:22:18

+0

表單標記是什麼樣的?我猜'selectform'是它的名字,在這種情況下你需要設置一個id。 – 2011-03-22 04:38:45

+0

不,我改變了

這樣。仍然顯示selwindow.document.getElementById('selectform')爲空錯誤 – Prabakaran 2011-03-22 04:44:21