我正在使用 jQuery 打开一个弹出窗口,我想在它打开时使用 post 方法向其发送数据。任何人都可以帮助我,提前致谢。
我目前正在使用 get 方法传递数据,因此数据是 url 中的一部分,但我不希望数据在 url 中可见。
function openWindow(){
var name = $('#name').val();
var url = 'popup_window.php?name='+name;
window.open(
url,
'popUpWindow',
'height=400, \
width=650, \
left=300, \
top=100, \
resizable=yes, \
scrollbars=yes, \
toolbar=yes, \
menubar=no, \
location=no, \
directories=no, \
status=yes');
}
这是基于中的答案如何打开弹出窗口并用父窗口中的数据填充它?
var newpage;
function openWindow() {
$.post('popup_window.php', {name: $('#name').val()}, function(result) {
newpage = result;
window.open('Popup.html', 'popUpWindow','height=400, width=650, left=300, top=100, resizable=yes, scrollbars=yes, toolbar=yes, menubar=no, location=no, directories=no, status=yes');
});
}
Popup.html 应包含:
<script type="text/javascript">
if(window.opener && !window.opener.closed) {
document.write(window.opener.newpage);
}
</script>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)