打开一个新的弹出窗口并将数据发布到它 [英] Open a new popup window and post data to it

查看:29
本文介绍了打开一个新的弹出窗口并将数据发布到它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jQuery 打开一个弹出窗口,我想在它打开时使用 post 方法向它发送数据.谁能帮帮我,提前谢谢.

I'm using jQuery to open a popup and I'd like to send it data using the post method when it opens. Can anyone help me, thanks in advance.

我目前正在使用 get 方法传递数据,因此数据是 url 中的一部分,但我不希望数据在 url 中可见.

I am currently passing the data using the get method so the data is a part in url, but I don't want the data to be visible in the 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 应包含:

Popup.html should contain:

<script type="text/javascript">
    if(window.opener && !window.opener.closed) {
        document.write(window.opener.newpage);
    }
</script>

这篇关于打开一个新的弹出窗口并将数据发布到它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆