2014-11-07 36 views
0

我試圖將數據從子窗口傳遞到父窗口。如何使用Javascript和/或JSP將數據從子窗口傳遞到父窗口

我想使用opener.location.href =「test.jsp?param =」+ param +「」;

但它不斷給我下面的錯誤:「未捕獲的SyntaxError:意外的字符串」

我不知道爲什麼它給出了錯誤,因爲opener.location.href應該接受字符串。

這是我的孩子的JS代碼。

function something(){ 
var param = document.getElementById("input"); //where input is a text field 

var link = 'http://localhost:8080/training/TestCases/test.jsp?param='+param''; 
opener.location.href = link; 
window.close(); 

}

一旦這個工作,我打算通過傳遞的參數,以獲得在我父母的JSP文件中的參數。

+0

額外 '' 在鏈接的結束...... – 2014-11-07 00:48:57

回答

0
var link = 'http://localhost:8080/training/TestCases/test.jsp?param='+param''; 

應該

var link = 'http://localhost:8080/training/TestCases/test.jsp?param='+param; 
+0

非常感謝!有效。 – Obviously 2014-11-07 07:19:49

相關問題