我一直在研究这个小脚本,翻译的文本应该返回原来的位置。一切似乎都很好,但是js仍然无法找到窗口对象。代码有什么问题吗?我也试过newXWin.document,但没用。请协助。
<?php
?>
<html>
<head>
<script>
function DoMagic()
{
var newWin = window.open("https://translate.google.com/#auto/es/This%20is%20a%20test%20sentence.%0AI%20think%20I%20should%20try%20this.","newXWin","width=500,height=600");
}
function GetText()
{
alert(window.opener.document.getElementById("result_box").innerHTML + "");
}
</script>
</head>
<body>
<div id='toDiv'></div>
<a href='#' onclick='javascript:DoMagic();'>Get Page</a>
<a href='#' onclick='javascript:GetText();'>Get Contents!</a>
</body>
</html>
&#13;