nobita21
03-10-2013, 10:35
Mình có trang 1 chứa text box để khi mở popup trang 2 ra rồi bấm nút thì giá trị quay về trang 1
Điều này xảy ra tốt khi cùng 1 domain, khác domain nhau thì tịt ngay
Cùng domain: http://static.giaophanthaibinh.org/test.html
Khác dommain: http://giaophanthaibinh.org/test.html
Mình đã thử cross domain nhưng ko thành công. Mong các bạn giúp
Code như sau
Trang 1:
<input type="text" id="txtImage" runat="server" width="300px" />
<input type="button" id="btnBrowsePicture" value="Mở popup" onclick="open_pop('http://static.giaophanthaibinh.org/index.html');" />
<script type="text/javascript">
function open_pop(URL) {
popupWindow = window.open(URL, 'popup', 'dependent=0,height=400px,width=750px,screenX=1,le ft=197,screenY=1,top=120,channelmode=0,dependent=0 ,directories=0,fullscreen=0,location=0,menubar=0,r esizable=1,scrollbars=1,status=0,toolbar=0', 'launcher');
if (window.focus) {
popupWindow.focus();
}
}
</script>
Trang 2:
<input type="button" value="Chèn vào Form đã mở" onclick="javascript:onSubmitOK('txtImage', 'string demo')" />
<script type="text/javascript">
function onSubmitOK(txtImgId, value) {
var oObjectID = null;
if (!window.opener.closed) {
oObjectID = window.opener.document.getElementById(txtImgId);
// oObjectID = document.getElementById('txtImgId')
if (oObjectID != null) {
oObjectID.value = value;
oObjectID.focus();
}
}
window.close();
}
</script>
Xin cảm ơn!!!
Điều này xảy ra tốt khi cùng 1 domain, khác domain nhau thì tịt ngay
Cùng domain: http://static.giaophanthaibinh.org/test.html
Khác dommain: http://giaophanthaibinh.org/test.html
Mình đã thử cross domain nhưng ko thành công. Mong các bạn giúp
Code như sau
Trang 1:
<input type="text" id="txtImage" runat="server" width="300px" />
<input type="button" id="btnBrowsePicture" value="Mở popup" onclick="open_pop('http://static.giaophanthaibinh.org/index.html');" />
<script type="text/javascript">
function open_pop(URL) {
popupWindow = window.open(URL, 'popup', 'dependent=0,height=400px,width=750px,screenX=1,le ft=197,screenY=1,top=120,channelmode=0,dependent=0 ,directories=0,fullscreen=0,location=0,menubar=0,r esizable=1,scrollbars=1,status=0,toolbar=0', 'launcher');
if (window.focus) {
popupWindow.focus();
}
}
</script>
Trang 2:
<input type="button" value="Chèn vào Form đã mở" onclick="javascript:onSubmitOK('txtImage', 'string demo')" />
<script type="text/javascript">
function onSubmitOK(txtImgId, value) {
var oObjectID = null;
if (!window.opener.closed) {
oObjectID = window.opener.document.getElementById(txtImgId);
// oObjectID = document.getElementById('txtImgId')
if (oObjectID != null) {
oObjectID.value = value;
oObjectID.focus();
}
}
window.close();
}
</script>
Xin cảm ơn!!!