作者guancheng (Austin)
看板PHP
標題Re: [請益] 利用表單內的另開視窗連結,傳送陣列資料
時間Mon Sep 1 03:52:50 2008
換個方式,改用新視窗到舊視窗抓資料呢?
給妳一個範列try看看~~
===== test.htm =====
<script language="javascript">
var tmp = Array(1,2,3);
</script>
<a href="javascript:void(0);" onclick="window.open('test2.htm');">另開視窗</a>
===== test2.htm =====
<script language="javascript">
function show() {
obj = window.opener;
alert(obj.tmp[0]);
}
</script>
<a href="javascript:void(0);" onclick="window.close();">關閉視窗</a><br />
<a href="javascript:void(0);" onclick="show();">show</a>
這樣不管要傳什麼型態的資料應該都可以
建議在window.open之前把要傳過去的資料整理到一個變數(方便新視窗使用)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.240.2.28