主窗口:
<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>
我这里有一个传递参数变量的,数组的你自己弄吧父窗口:parent.htm
<script>
var
str
var
gaga=0
str
=window.showModalDialog("modal.htm",gaga,"dialogWidth=800pxdialogHeight=400px")
alert(str)
</script>
子窗口:modal.htm
<script>
var
ga=window.dialogArguments
document.write("传递过来的是:"+ga+"
现在我要加1,传递回去")
ga=ga+1
window.returnValue=ga
</script>