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

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

问题描述

我正在使用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中的一部分,但我不希望数据在网址中可见。

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天全站免登陆