wow kesana kemari nyari nyari akhirnya ketemu juga
langsung aja,
ini script window opener,
bisa di bilang mengambil value dari new window
kemudian valuenya di tempatkan di main window..
kalo mau lebih jelasnya langsung praktek aja ye
ini halaman main
<html>
<head>
<script language="javascript" type="text/javascript">
function GetValueFromChild(myVal)
{
document.getElementById('mytxt').value = myVal;
}
</script>
</head>
<body>
<input id="mytxt" type="text" />
<input type="button" onclick="window.open('parent.php','parent','width=500px,height=500px')" value="pilih" />
</body>
</html>
kemudian buat halaman ketika di click / new window
<html>
<head>
<script language="javascript" type="text/javascript">
function SendValueToParent(asd)
{
var myVal = document.getElementById(asd).innerHTML;
window.opener.GetValueFromChild(myVal);
window.close();
return false;
}
function SendValueToParent2(asd)
{
var myVal = document.getElementById(asd).value;
window.opener.GetValueFromChild(myVal);
window.close();
return false;
}
</script>
</head>
<body>
Type text here and send it to parent window:
<input id="mytxt4" type="text" />
<br />
<input id="btn1"��� type="button" value="Send Value to Parent" onclick="javascript:return SendValueToParent2('mytxt4');" />
<br />
<span id="mytxt" onclick="javascript:return SendValueToParent('mytxt');" style="cursor:pointer">asdfg</span><br />
<span id="mytxt2" onclick="javascript:return SendValueToParent('mytxt2');" style="cursor:pointer">zxcv</span><br />
<span id="mytxt3" onclick="javascript:return SendValueToParent('mytxt3');" style="cursor:pointer">qwert</span>
</body>
</html>
it's simply
keren kan
silahkan di coba
Tidak ada komentar:
Posting Komentar
silahkan komentar anda