首页 > Windows开发 > 详细

window.open()

时间:2019-08-29 18:02:32      阅读:106      评论:0      收藏:0      [点我收藏+]

一、核心

1、做按钮监听,打开窗口

 function foo() {

         window.open(‘/add/‘, ‘‘, ‘width=400,height=200,top=500, left=300‘)
    }

2、执行post请求后,返回一个额外的页面

def add_publish(request):
    if request.method == "POST":
        publisher = request.POST.get("publisher")
        print(publisher)
        # models.Publish.objects.create(name=publisher)
        return render(request, "pop.html", {"publish": publisher})
    return render(request, "add_publish.html")

3、在这个页面添加 调用父窗口的函数,关闭窗口

<script>
    window.opener.bar("{{ publish }}");
    window.close();
</script>

4、注意主页面的被调用的函数

    function bar(data) {
        console.log(data);

        $(".my-bar").text(data)

 

window.open()

原文:https://www.cnblogs.com/wt7018/p/11431182.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!