方法一~~~~~~~~~~~~~~~~~~~~~~
主窗口:
<input name="" type="button" onclick="newpage()"/>
<script>
var a = "12345";
function newpage(){
window.open("子窗口.html" + "?" + a);
}
</script>
子窗口.html
<script>
var addstr= document.URL;
var num=addstr.indexOf("?")
addstr=addstr.substr(num+1);
alert(addstr);
</script>
方法二:~~~~~~~~~~~~~~~~~~~~~~~
主窗口:
<input id="hid" type="hidden" value="" />
<input name="" type="button" onclick="newpage()"/>
<script>
var a = "12345";
function newpage(){
document.getElementById("hid").value = a;
window.open("2.html");
}
</script>
子窗口:
<script>
var prtW = window.opener;
var prtA;
if(prtW!=null){
prtA = prtW.document.getElementById("hid").value;
alert(prtA);
}
</script>
下面有两个附件,我自己做的。很简单的,大家可以自己玩玩!